I'm trying to run the interactive cli-platform
examples, but they all seem to hang during the "Rebuilding host" stage.
Am I missing a required step to running them?
cargo run examples/interactive/echo.roc
and cargo run examples/interactive/countdown.roc
are working for me, can you try these commands from the root of the repo dir?
also they might just take awhile to build, since some of them have Rust hosts - so it's waiting for a full cargo
build
unfortunately they don't currently pipe the output, so you can't see what the host rebuilding is doing :sweat_smile:
so I might also try just letting it run for awhile and seeing if it finishes
one way to check would be to try cargo run examples/hello-world/main.roc
or cargo run examples/hello-world/zig-platform/helloZig.roc
- those use C and Zig hosts, respectively, so they should rebuild the host very fast
Richard Feldman said:
so I might also try just letting it run for awhile and seeing if it finishes
Thank you! Indeed, patience resolved it :blush:
I'm trying to run one, or any of the examples, but running into the same issue on all of them, when I do a cargo run ./path/to/example/dir
I receive the following error message in response:
ian@UBU:~/Documents/repos/roc$ cargo run ./examples/hello-world/
Finished dev [unoptimized + debuginfo] target(s) in 1.59s
Running `target/debug/roc ./examples/hello-world/`
thread 'main' panicked at '`wasm-stack-size-kb` is not an id of an argument or a group.
Make sure you're using the name of the argument itself and not the name of short or long flags.', crates/cli/src/lib.rs:528:10
Any idea what's causing the issue with the wasm-stack-size-kb
flag? Also, where are these flags set?
Last I tried, it's cargo run ./path/to/file.roc
- does that work?
Each example dir has one or more runnable Roc app files in it
Regardless, that error message is wild and definitely should be reported as a GH issue. Thanks for finding this!
Thanks @JanCVanB , tried that, but same issue. I can definitely open a GH issue for this
@Brian Carroll might have an idea. He deals with the wasm backend. Sounds like a bug with a flag.
@Brendan Hansknecht is WASM the default compile target?
No, but i think that flag is new, so maybe they messed something up when adding it.
What commit are you on? There was a patch that was supposed to fix this in https://github.com/roc-lang/roc/commit/1f45d13c67a5aa68e70c051af44a265c4e65f3e8
Ayaz Hafiz Ah, thank you! I was on 4cb5de442 - I just did a pull today before asking, but turns out I was on the old trunk branch from the rtfeldman repo. Oops!
Should I be expecting running all the examples to work? Or are they kind of aspirational/WIP code?
more or less they should all work if you have the correct dependencies installed
Right okay. Any pointers for what I'm doing wrong here?
# mario ~/Downloads/roc_nightly-macos_12_apple_silicon-2022-10-19-e90ddcd 19:53:12
$ ./roc run ~/dev/projects/roc/examples/cli/http-get.roc
π¨ Rebuilding platform...
ββ TYPE MISMATCH β ...ario/dev/projects/roc/examples/cli/cli-platform/main.roc β
Something is off with the type annotation of the main required symbol:
2β requires {} { main : InternalProgram }
^^^^^^^^^^^^^^^
This #UserApp.main value is a:
(List Str -> Task.Task {} [] [Network [Http], Read [Stdin],
Write [Stdout]] ?)
But the type annotation on main says it should be:
InternalProgram.InternalProgram ?
Tip: Type comparisons between an opaque type are only ever equal if
both types are the same opaque type. Did you mean to create an opaque
type by wrapping it? If I have an opaque type Age := U32 I can create
an instance of this opaque type by doing @Age 23.
ββ TYPE MISMATCH β ...ario/dev/projects/roc/examples/cli/cli-platform/main.roc β
This 1st argument to toEffect has an unexpected type:
9β mainForHost = InternalProgram.toEffect main
^^^^
This #UserApp.main value is a:
(List Str -> Task.Task {} [] [Network [Http], Read [Stdin],
Write [Stdout]] ?)
But toEffect needs its 1st argument to be:
InternalProgram.InternalProgram ?
Tip: Type comparisons between an opaque type are only ever equal if
both types are the same opaque type. Did you mean to create an opaque
type by wrapping it? If I have an opaque type Age := U32 I can create
an instance of this opaque type by doing @Age 23.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
2 errors and 0 warnings found in 2838 ms.
Running program anywayβ¦
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Roc crashed with:
Erroneous: specialize_symbol
Here is the call stack that led to the crash:
.mainForHost
Optimizations can make this list inaccurate! If it looks wrong, try running without `--optimize` and with `--linker=legacy`
It looks like that example doesn't run in ci (probably don't want a ci test depending on http get) so it is probably out of date now that the cli platform has been updated.
Okie. What about echo?
$ ./roc run ~/dev/projects/roc/examples/cli/echo.roc
thread 'main' panicked at 'internal error: entered unreachable code: symbol/layout `22.IdentId(29)` ProcLayout {
arguments: [
Struct {
field_order_hash: FieldOrderHash(
0,
),
field_layouts: [],
},
LambdaSet(
LambdaSet {
set: [
( 22.29, [LambdaSet(LambdaSet { set: [], representation: Interned(0, PhantomData) }), LambdaSet(LambdaSet { set: [( 20.20, [])], representation: Interned(1, PhantomData) })]),
],
representation: Interned(
2,
PhantomData,
),
},
),
],
result: Builtin(
Int(
U8,
),
),
captures_niche: CapturesNiche(
[
LambdaSet(
LambdaSet {
set: [],
representation: Interned(
0,
PhantomData,
),
},
),
LambdaSet(
LambdaSet {
set: [
( 20.20, []),
],
representation: Interned(
1,
PhantomData,
),
},
),
],
),
} combo must be in DeclarationToIndex', crates/compiler/mono/src/borrow.rs:165:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
That one definitely used to be tested in CI, let me take a look
hmm...not tested in CI. This one probably should be. It has a super minor bug: main = Program.noArgs mainTask
-> main = Program.withArgs mainTask
or more correctly, it doesn't use args so change the main task to no longer take args.
Thanks for catching this.
Cool, that works! I can do a PR if helpful?
If you want to, that would be great
Otherwise, I can get to it at some point
Also, fixing http-get.roc
should be pretty easy as well. It just needs to update to use Program.noArgs
as well. It is still trying to set main to be a task
Hrm, had a bash but no bueno...
No worries. I can make a PR later today
Fixed the one you mentioned but couldn't get the HTTP one going. Errors out of my depth unfort.
Uploading Screenshot 2022-10-21 at 20.42.49.pngβ¦
Just added PR #4374 to fix those two examples. Also filed an issue around ensure all examples have tests, that used to be the case, but things changed and I guess it is not the case anymore.
Awesome, http-get example working for me now :)
I notice that π¨ Rebuilding platform
happens every time I run it. What's the reason for this?
I think it's mainly because of convenience for us to ensure that when the code for building changes we're not using some old cached platform. You can skip this with the flag --prebuilt-platform true
.
Last updated: Jul 05 2025 at 12:14 UTC