Stream: beginners

Topic: Running the examples


view this post on Zulip Qqwy / Marten (Jun 18 2022 at 08:35):

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?

view this post on Zulip Anton (Jun 18 2022 at 08:52):

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?

view this post on Zulip Richard Feldman (Jun 18 2022 at 13:19):

also they might just take awhile to build, since some of them have Rust hosts - so it's waiting for a full cargo build

view this post on Zulip Richard Feldman (Jun 18 2022 at 13:19):

unfortunately they don't currently pipe the output, so you can't see what the host rebuilding is doing :sweat_smile:

view this post on Zulip Richard Feldman (Jun 18 2022 at 13:20):

so I might also try just letting it run for awhile and seeing if it finishes

view this post on Zulip Richard Feldman (Jun 18 2022 at 13:20):

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

view this post on Zulip Qqwy / Marten (Jun 20 2022 at 10:57):

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:

view this post on Zulip Ian McLerran (Aug 19 2022 at 21:35):

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?

view this post on Zulip jan kili (Aug 19 2022 at 21:36):

Last I tried, it's cargo run ./path/to/file.roc - does that work?

view this post on Zulip jan kili (Aug 19 2022 at 21:37):

Each example dir has one or more runnable Roc app files in it

view this post on Zulip jan kili (Aug 19 2022 at 21:40):

Regardless, that error message is wild and definitely should be reported as a GH issue. Thanks for finding this!

view this post on Zulip Ian McLerran (Aug 19 2022 at 21:42):

Thanks @JanCVanB , tried that, but same issue. I can definitely open a GH issue for this

view this post on Zulip Brendan Hansknecht (Aug 19 2022 at 23:51):

@Brian Carroll might have an idea. He deals with the wasm backend. Sounds like a bug with a flag.

view this post on Zulip Ian McLerran (Aug 20 2022 at 00:21):

@Brendan Hansknecht is WASM the default compile target?

view this post on Zulip Brendan Hansknecht (Aug 20 2022 at 00:24):

No, but i think that flag is new, so maybe they messed something up when adding it.

view this post on Zulip Ayaz Hafiz (Aug 20 2022 at 02:10):

What commit are you on? There was a patch that was supposed to fix this in https://github.com/roc-lang/roc/commit/1f45d13c67a5aa68e70c051af44a265c4e65f3e8

view this post on Zulip Ian McLerran (Aug 20 2022 at 03:30):

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!

view this post on Zulip Mario (Oct 21 2022 at 18:53):

Should I be expecting running all the examples to work? Or are they kind of aspirational/WIP code?

view this post on Zulip Brendan Hansknecht (Oct 21 2022 at 18:53):

more or less they should all work if you have the correct dependencies installed

view this post on Zulip Mario (Oct 21 2022 at 18:53):

Right okay. Any pointers for what I'm doing wrong here?

view this post on Zulip Mario (Oct 21 2022 at 18:54):

# 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`

view this post on Zulip Brendan Hansknecht (Oct 21 2022 at 18:55):

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.

view this post on Zulip Mario (Oct 21 2022 at 18:56):

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

view this post on Zulip Brendan Hansknecht (Oct 21 2022 at 18:57):

That one definitely used to be tested in CI, let me take a look

view this post on Zulip Brendan Hansknecht (Oct 21 2022 at 19:00):

hmm...not tested in CI. This one probably should be. It has a super minor bug: main = Program.noArgs mainTask -> main = Program.withArgs mainTask

view this post on Zulip Brendan Hansknecht (Oct 21 2022 at 19:00):

or more correctly, it doesn't use args so change the main task to no longer take args.

view this post on Zulip Brendan Hansknecht (Oct 21 2022 at 19:00):

Thanks for catching this.

view this post on Zulip Mario (Oct 21 2022 at 19:28):

Cool, that works! I can do a PR if helpful?

view this post on Zulip Brendan Hansknecht (Oct 21 2022 at 19:28):

If you want to, that would be great

view this post on Zulip Brendan Hansknecht (Oct 21 2022 at 19:29):

Otherwise, I can get to it at some point

view this post on Zulip Brendan Hansknecht (Oct 21 2022 at 19:29):

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

view this post on Zulip Mario (Oct 21 2022 at 19:43):

Hrm, had a bash but no bueno...

view this post on Zulip Brendan Hansknecht (Oct 21 2022 at 19:50):

No worries. I can make a PR later today

view this post on Zulip Mario (Oct 21 2022 at 21:14):

Fixed the one you mentioned but couldn't get the HTTP one going. Errors out of my depth unfort.

view this post on Zulip Mario (Oct 21 2022 at 21:14):

Uploading Screenshot 2022-10-21 at 20.42.49.png…

view this post on Zulip Brendan Hansknecht (Oct 21 2022 at 22:03):

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.

view this post on Zulip Mario (Oct 22 2022 at 07:22):

Awesome, http-get example working for me now :)

view this post on Zulip Mario (Oct 22 2022 at 07:24):

I notice that πŸ”¨ Rebuilding platform happens every time I run it. What's the reason for this?

view this post on Zulip Anton (Oct 22 2022 at 07:54):

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