Stream: advent of code

Topic: Setting up environment


view this post on Zulip Braydon Hall (Dec 01 2022 at 05:20):

I'm already struggling to even setup an environment to work in :sweat_smile:

view this post on Zulip Braydon Hall (Dec 01 2022 at 05:20):

What's the best way to setup a cli project?

view this post on Zulip Luke Boswell (Dec 01 2022 at 06:10):

Are you wanting to write just Roc apps? If you can download a nightly release binary from github, then make sure it is in your path. Then you can run a basic-cli app from anywhere with roc run myApp.roc.

I'm not an expert, so apologise in advance if this doesn't work for you, but I'm pretty sure that's all.

For an example app you could look at my AoC 2021 Day 1. It's not great, but shows the basics I think. Note that example links to an older URL release of basic-cli, so maybe update the url from the basic-cli repo if you want the latest version.

view this post on Zulip Braydon Hall (Dec 01 2022 at 06:25):

I just commandeered the helloWorld.roc file from examples for now :joy:

Now I'm running into frustrations by not being able to use dbg though. It just isn't giving me anything!

view this post on Zulip Luke Boswell (Dec 01 2022 at 06:26):

Can you share an example?

view this post on Zulip Braydon Hall (Dec 01 2022 at 06:38):

Hah! Of course as always, a minimal repro works. Man, this is really making me think, haha.

view this post on Zulip Richard Feldman (Dec 01 2022 at 06:51):

dbg just landed last week, so it's very not battle tested...a non minimal repo would still be helpful if you have time to open an issue with it!

view this post on Zulip Asier Elorz (he/him) (Dec 02 2022 at 18:41):

Hi. I am following the roc tutorial with the intention of getting the basics and then doing advent of code in roc this year. However, in the "Building an application" step, I get a panic at the compiler when trying to build the example hello world program. The problem seems to be related to downloading or compiling the platform from the GitHub releases link.

This is the error message I am getting, with the stacktrace:

~/Desktop/advent-of-code-2022/day-1-1  roc dev day-1-1.roc

Downloading https://github.com/roc-lang/basic-cli/releases/download/0.1.1/zAoiC9xtQPHywYk350_b7ust04BmWLW00sjb9ZPtSQk.tar.br
    into /home/asier/.cache/roc/packages

thread 'main' panicked at 'not yet implemented: TODO gracefully handle package install error IoErr(Os { code: 18, kind: CrossesDevices, message: "Invalid cross-device link" })', crates/compiler/load_internal/src/file.rs:3859:37
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:142:14
   2: roc_load_internal::file::parse_header
   3: roc_load_internal::file::load_filename
   4: roc_load_internal::file::LoadStart::from_path
   5: roc_load::load_and_monomorphize
   6: roc_cli::build::build_file
   7: roc_cli::build
   8: roc::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Just in case, the program I am trying to build is exactly this:

app "Advent of code - Day 1 - Problem 1"
    packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.1.1/zAoiC9xtQPHywYk350_b7ust04BmWLW00sjb9ZPtSQk.tar.br" }
    imports [pf.Stdout]
    provides [main] to pf

main =
    Stdout.line "I'm a Roc application"

I am using a Manjaro Linux with all rolling release dependencies updated today. The roc version I am using is roc_nightly-linux_x86_64-2022-12-02-0d80e74.tar.gz, or roc --version "roc nightly pre-release, built from commit 0d80e74 on Fr 02 Dez 2022 09:08:27 UTC"

I'm not sure if this channel is the right place to ask, but I hope so, since it is about setting up the environment for advent of code.

view this post on Zulip Pearce Keesling (Dec 02 2022 at 18:49):

Yeah, I also gave up trying to use dbg, I'll try to make a repro tomorrow when I'm back on that machine doing day3

view this post on Zulip Brian Carroll (Dec 02 2022 at 18:51):

The string after app is supposed to be the name of the executable. Try removing the spaces?

view this post on Zulip Brian Carroll (Dec 02 2022 at 18:51):

Also what's the Roc filename?

view this post on Zulip Asier Elorz (he/him) (Dec 02 2022 at 18:53):

The name of the file is day-1-1.roc

view this post on Zulip Asier Elorz (he/him) (Dec 02 2022 at 18:54):

I tried changing the name of the file to day11.roc and the app name to "AOC1" and I get the same error. I don't think I can get names simpler than that. I would guess the problem is somewhere else.

view this post on Zulip Anton (Dec 02 2022 at 18:56):

I have a Manjaro VM, I'll try to reproduce this tomorrow.

view this post on Zulip Braydon Hall (Dec 02 2022 at 19:05):

@Asier Elorz (he/him) I have the exact same issue on my Fedora box when trying to use the basic cli platform from github releases - the download fails.

What I have been dong instead, is placing my roc files at the top level for the roc repo examples folder, and copying the platform path from helloWorld.roc. That at least has gotten me up and running

view this post on Zulip Richard Feldman (Dec 02 2022 at 19:05):

@Braydon Hall what OS is this on?

view this post on Zulip Braydon Hall (Dec 02 2022 at 19:06):

Haha, just updated, sorry. Fedora 35

view this post on Zulip Asier Elorz (he/him) (Dec 02 2022 at 19:14):

I have more information. I downloaded and decompressed the platform, then tried to reference it locally. I am not sure if I am doing it correctly, but just in case I will post the message.

The program now is:

app "advent-of-code-1-1"
    packages { pf: "../Platform/main.roc" }
    imports [pf.Stdout]
    provides [main] to pf

main =
    Stdout.line "I'm a Roc application"

where ~/Desktop/advent-of-code-2022/Platform is a directory that contains the contents of the .tar.br in the GitHub releases page and nothing else.

The error message now is:

~/Desktop/advent-of-code-2022/day-1-1  roc dev day-1-1.roc
🔨 Rebuilding platform...
An internal compiler expectation was broken.
This is definitely a compiler bug.
Please file an issue here: https://github.com/roc-lang/roc/issues/new/choose
thread '<unnamed>' panicked at 'failed to open file "../Platform/dynhost": No such file or directory (os error 2)', crates/linker/src/lib.rs:513:29
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:142:14
   2: roc_linker::open_mmap
   3: roc_linker::elf::preprocess_elf
   4: roc_linker::build_and_preprocess_host
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread 'main' panicked at 'Failed to (re)build platform.: Any { .. }', crates/cli/src/build.rs:342:46
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:142:14
   2: core::result::unwrap_failed
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/result.rs:1814:5
   3: roc_cli::build::build_file
   4: roc_cli::build
   5: roc::main

I am posting it since it says it is definitely a compiler bug. I have also submitted an issue to GitHub as the error message suggests: https://github.com/roc-lang/roc/issues/4663


Last updated: Jul 06 2025 at 12:14 UTC