Stream: bugs

Topic: platform templates outdated


view this post on Zulip jan kili (Nov 03 2024 at 23:43):

Hey @Luke Boswell, am I using your platform templates wrong, or did a Roc update in the last 6 months break them all?

jan@mackey roc-platform-template-rust % roc build.roc
── STATEMENT AFTER EXPRESSION in ...tFmNkvEICPErI9ptji_ySjicO6CkucY/Effect.roc ─

I just finished parsing an expression with a series of definitions,

and this line is indented as if it's intended to be part of that
expression:

 1│  hosted Effect
 2│      exposes [
 3│          Effect,
 4│          after,
 5│          args,
 6│          map,
 7│          always,
 8│          forever,
 9│          loop,
10│          dirList,
11│          dirCreate,
12│          dirCreateAll,
13│          dirDeleteEmpty,
14│          dirDeleteAll,
15│          envDict,
16│          envVar,
17│          cwd,
18│          setCwd,
19│          exePath,
20│          stdoutLine,
21│          stdoutWrite,
22│          stderrLine,
23│          stderrWrite,
24│          stdinLine,
25│          stdinBytes,
26│          ttyModeCanonical,
27│          ttyModeRaw,
28│          sendRequest,
29│          fileReadBytes,
30│          fileDelete,
31│          fileWriteUtf8,
32│          fileWriteBytes,
33│          pathType,
34│          posixTime,
35│          tcpConnect,
36│          tcpClose,
37│          tcpReadUpTo,
38│          tcpReadExactly,
39│          tcpReadUntil,
40│          tcpWrite,
41│          sleepMillis,
42│          commandStatus,
43│          commandOutput,
44│      ]
45│      imports [
46│          InternalHttp.{ Request, InternalResponse },
47│          InternalFile,
48│          InternalTcp,
49│          InternalCommand,
50│          InternalPath,
51│      ]
52│      generates Effect with [after, map, always, forever, loop]
53│
54│  stdoutLine : Str -> Effect (Result {} Str)
     ^

However, I already saw the final expression in that series of
definitions.

Tip: An expression like `4`, `"hello"`, or `functionCall MyThing` is
like `return 4` in other programming languages. To me, it seems like
you did `return 4` followed by more code in the lines after, that code
would never be executed!

Tip: If you are working with `Task`, this error can happen if you
forgot a `!` somewhere.%
jan@mackey roc-platform-template-rust %

I get this error in all of them:
https://github.com/lukewilliamboswell/roc-platform-template-c
https://github.com/lukewilliamboswell/roc-platform-template-go
https://github.com/lukewilliamboswell/roc-platform-template-rust
https://github.com/lukewilliamboswell/roc-platform-template-swift
https://github.com/lukewilliamboswell/roc-platform-template-zig

view this post on Zulip Luke Boswell (Nov 03 2024 at 23:44):

They're definitely outdated.

view this post on Zulip Luke Boswell (Nov 03 2024 at 23:44):

I have been planning on giving them some love/uplift once purity inference lands. Though I wasn't tracking they were broken

view this post on Zulip Luke Boswell (Nov 03 2024 at 23:45):

After purity inference the host API get's so much nicer

view this post on Zulip Luke Boswell (Nov 03 2024 at 23:46):

I'm also thinking of killing the repo https://github.com/lukewilliamboswell/roc-glue-code-gen and removing all references to that. It was an idea I had but probably a bit too ambitious to try and get Glue scripts for all the different languages.

view this post on Zulip Luke Boswell (Nov 03 2024 at 23:46):

My recommendation for rust platforms now is just to pin to the roc repo roc_std etc

view this post on Zulip Luke Boswell (Nov 03 2024 at 23:47):

And for zig, that's still a bit hand rolled. You can copy-paste the builtins, but there is a lot of stuff in there that's not needed. So it's not really a std library implementation.

view this post on Zulip jan kili (Nov 03 2024 at 23:48):

Luke Boswell said:

My recommendation for rust platforms now is just to pin to the roc repo roc_std etc

Sweet, can you link me an example of this to copy/paste?

view this post on Zulip Luke Boswell (Nov 03 2024 at 23:48):

For the others, everything needs to be hand rolled. Though it's totally doable for simple types like u64, i64 and structs etc

view this post on Zulip Luke Boswell (Nov 03 2024 at 23:48):

https://github.com/lukewilliamboswell/roc-ray/blob/main/Cargo.toml

view this post on Zulip jan kili (Nov 03 2024 at 23:48):

Let me know if there's anything actionable I can help with https://roc.zulipchat.com/#narrow/channel/316715-contributing/topic/Help.20upgrade.2Ftest.20purity.20inference/near/478391839 :smile:

view this post on Zulip Luke Boswell (Nov 03 2024 at 23:49):

https://github.com/lukewilliamboswell/roc-ray/blob/main/Cargo.toml

I've been spending most of my time lately in roc-ray... so that's all up to date. The purity-inference branch is the bleeding edge.
Sweet, can you link me an example of this to copy/paste?

view this post on Zulip Luke Boswell (Nov 03 2024 at 23:52):

JanCVanB said:

Let me know if there's anything actionable I can help with https://roc.zulipchat.com/#narrow/channel/316715-contributing/topic/Help.20upgrade.2Ftest.20purity.20inference/near/478391839 :smile:

My general thoughts on this is that without early return, try and purity-inference in the nightlies, it's going to be a challenge to get basic-cli upgraded. The examples lean very heavily on unwrapping Results. I've done the platform and the host, so it's just the examples now that need doing. It should only be an hour or so to do once everything else is ready.

view this post on Zulip jan kili (Nov 03 2024 at 23:57):

Overwriting roc-platform-template-rust/Cargo.toml with roc-ray/Cargo.toml doesn't influence that roc build.roc error. Did you have a nontrivial patch in mind?
Screen Shot 2024-11-03 at 4.55.20 PM.png

view this post on Zulip Luke Boswell (Nov 04 2024 at 00:06):

Sorry, I didn't mean copy the whole thing... I was just referring to this part

roc_std = { git = "https://github.com/roc-lang/roc.git" }
roc_std_heap = { git = "https://github.com/roc-lang/roc.git" }

view this post on Zulip jan kili (Nov 04 2024 at 00:07):

Still nope :stuck_out_tongue:
Screen Shot 2024-11-03 at 5.07.11 PM.png

view this post on Zulip Luke Boswell (Nov 04 2024 at 00:07):

Currently the crate roc_host get's it's roc_std dependency from another crate in the same workspace (in the repo) but instead I think it's better to just point at the roc repo instead of vendoring it

view this post on Zulip Luke Boswell (Nov 04 2024 at 00:08):

Yeah, and then in the roc_host Cargo.toml you will need to use the workspace dependency

view this post on Zulip Luke Boswell (Nov 04 2024 at 00:08):

Or it is probably easier just to put that dep in the crates/roc_host/Cargo.toml

view this post on Zulip Luke Boswell (Nov 04 2024 at 00:08):

Instead of the root workspace Cargo.toml

view this post on Zulip Luke Boswell (Nov 04 2024 at 00:09):

We won't need the roc_std_heap dependency for the template

view this post on Zulip jan kili (Nov 04 2024 at 00:10):

Still nope?
Screen Shot 2024-11-03 at 5.09.48 PM.png

view this post on Zulip jan kili (Nov 04 2024 at 00:21):

Yay, the fix you just pushed yields a much later error!

jan@mackey roc-platform-template-rust % git pull
remote: Enumerating objects: 24, done.
remote: Counting objects: 100% (24/24), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 14 (delta 8), reused 14 (delta 8), pack-reused 0 (from 0)
Unpacking objects: 100% (14/14), 2.85 KiB | 224.00 KiB/s, done.
From https://github.com/lukewilliamboswell/roc-platform-template-rust
   9e44526..399fc2d  main       -> origin/main
Updating 9e44526..399fc2d
Fast-forward
 README.md                  |  4 ----
 build.roc                  |  7 +------
 bundle.sh                  | 24 ++++++++++++++++++++++++
 crates/roc_host/Cargo.toml |  2 +-
 glue.roc                   | 27 ---------------------------
 platform/Effect.roc        | 10 +---------
 platform/Stdout.roc        |  4 +---
 platform/main.roc          |  4 ++--
 8 files changed, 30 insertions(+), 52 deletions(-)
 create mode 100644 bundle.sh
 delete mode 100644 glue.roc
jan@mackey roc-platform-template-rust % roc build.roc
Downloading https://github.com/roc-lang/basic-cli/releases/download/0.15.0/SlwdbJ-3GR7uBWQo6zlmYWNYOxnvo8r6YABXD-45UOw.tar.br
    into /Users/jan/.cache/roc/packages

[8.6 / 8.6 MB]
BUILD INFO: Geting native target...
BUILD INFO: Building cargo; mode: DEBUG for target MacosX64...
    Updating crates.io index
    Updating git repository `https://github.com/roc-lang/roc.git`
warning: skipping duplicate package `host` found at `/Users/jan/.cargo/git/checkouts/roc-f2007fde281427d6/69dd8d7/examples/glue/rust-platform`
warning: skipping duplicate package `host` found at `/Users/jan/.cargo/git/checkouts/roc-f2007fde281427d6/69dd8d7/examples/cli/false-interpreter/platform`
warning: skipping duplicate package `host` found at `/Users/jan/.cargo/git/checkouts/roc-f2007fde281427d6/69dd8d7/examples/platform-switching/rust-platform`
  Downloaded arrayvec v0.7.6
  Downloaded libc v0.2.150
  Downloaded 2 crates (750.6 KB) in 0.42s
   Compiling libc v0.2.150
   Compiling static_assertions v1.1.0
   Compiling arrayvec v0.7.6
   Compiling roc_host v0.0.1 (/Users/jan/_code/_roc/roc-platform-template-rust/crates/roc_host)
   Compiling roc_std v0.0.1 (https://github.com/roc-lang/roc.git#69dd8d77)
error[E0658]: labels on blocks are unstable
   --> /Users/jan/.cargo/git/checkouts/roc-f2007fde281427d6/69dd8d7/crates/roc_std/src/roc_str.rs:630:21
    |
630 |         let start = 'blk: {
    |                     ^^^^
    |
    = note: see issue #48594 <https://github.com/rust-lang/rust/issues/48594> for more information

error[E0658]: labels on blocks are unstable
   --> /Users/jan/.cargo/git/checkouts/roc-f2007fde281427d6/69dd8d7/crates/roc_std/src/roc_str.rs:642:19
    |
642 |         let end = 'blk: {
    |                   ^^^^
    |
    = note: see issue #48594 <https://github.com/rust-lang/rust/issues/48594> for more information

For more information about this error, try `rustc --explain E0658`.
error: could not compile `roc_std` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
Program exited with error:
    (ErrBuildingRustTarget (CmdError (ExitCode -99)))

Tip: If you do not want to exit on this error, use `Task.mapErr` to handle the error.
Docs for `Task.mapErr`: <https://www.roc-lang.org/packages/basic-cli/0.15.0/Task#mapErr>
jan@mackey roc-platform-template-rust %

view this post on Zulip jan kili (Nov 04 2024 at 00:23):

No urgency on this - I'll take a look at your purity-inference work in roc-ray like you suggested via DM :dancing:

Update: I'll try again tomorrow to build the Roc compiler from source (on the purity-inference branch) on my other laptop running Fedora, cause this macbook is sad.

view this post on Zulip jan kili (Nov 05 2024 at 21:20):

Hey, does anyone know why might my cargo build be freezing at the roc_host build step of roc-platform-template-rust after trying to make some purity-inference updates? https://github.com/lukewilliamboswell/roc-platform-template-rust/pull/2/files

It's not just the , branch = "purity-inference" change in Cargo.toml, because the build succeeds if that's the only local change.

view this post on Zulip Luke Boswell (Nov 05 2024 at 21:31):

What happens if you cargo check?

view this post on Zulip jan kili (Nov 06 2024 at 01:03):

The same:

[jan@framey roc-platform-template-rust]$ cargo check
    Checking arrayvec v0.7.6
    Checking static_assertions v1.1.0
    Checking libc v0.2.150
   Compiling roc_host v0.0.1 (/home/jan/_code/_roc/roc-platform-template-rust/crates/roc_host)
    Checking roc_std v0.0.1 (https://github.com/roc-lang/roc.git?branch=purity-inference#2b8d9aa4)
^C  Building [================>           ] 7/11: roc_host(build)
[jan@framey roc-platform-template-rust]$ git switch main
Switched to branch 'main'
[jan@framey roc-platform-template-rust]$ cargo check
    Updating git repository `https://github.com/roc-lang/roc.git`
     Locking 1 package to latest compatible version
      Adding roc_std v0.0.1 (https://github.com/roc-lang/roc.git#544a5dcf)
   Compiling roc_host v0.0.1 (/home/jan/_code/_roc/roc-platform-template-rust/crates/roc_host)
    Checking roc_std v0.0.1 (https://github.com/roc-lang/roc.git#544a5dcf)
warning: roc_host@0.0.1: SUCCESSFULLY BUILT APP STUB DYNAMIC LIBRARY "/home/jan/_code/_roc/roc-platform-template-rust/platform/libapp.so"
    Checking host v0.0.1 (/home/jan/_code/_roc/roc-platform-template-rust/crates/roc_host_lib)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.82s
[jan@framey roc-platform-template-rust]$

Last updated: Jul 06 2025 at 12:14 UTC