anyone able to set up a nix shell with the latest main? i tried and it's complaining that
The package requires the Cargo feature called
workspace-inheritance
, but that feature is not stabilized in this version of Cargo (1.62.0).
what's weird is I tried to use nixpkgs-22.05 and nixpkgs-22.11 and both times it said Cargo 1.62 in the error. 22.05 had cargo 1.60, 22.11 has 1.64
my very naive attempt so far https://github.com/omnibs/aoc22/blob/7b4917904c7742f32082b8f5f4dfebf6f43e8f9f/shell.nix
i had this working for an older version of main, but i want dbg
:3
ohh ok so the derivation for roc uses a pinned version of nixpkgs, but we can override it!
ok overriding nixpkgs with 22.11 got me past that, but now I hit:
Compiling roc_docs v0.0.1 (/tmp/nix-build-roc-0.0.1.drv-0/2234iib1nswkawkigmaij7lg4gaf1fpp-roc-src/crates/docs)
Compiling roc_docs_cli v0.0.1 (/tmp/nix-build-roc-0.0.1.drv-0/2234iib1nswkawkigmaij7lg4gaf1fpp-roc-src/crates/docs_cli)
Finished release [optimized] target(s) in 2m 06s
Executing cargoInstallPostBuildHook
Finished cargoInstallPostBuildHook
Finished cargoBuildHook
buildPhase completed in 2 minutes 7 seconds
installing
Executing cargoInstallHook
cp: cannot stat 'target/x86_64-unknown-linux-gnu/release/lib/.': No such file or directory
this seems to come from this postInstall override
yeah, i don't have a lib/ dir at all
ive hundreds of files and a few other dirs, but no lib :S
i think i recall richard mentioning something about a change to ship stdlib along with roc, maybe this postInstall was a part of that? no idea
or unrelated, this postinstall seems pretty old
I don't think this lib
dir is related to that one, but I could be wrong!
i removed the cp
line and it built, but running the hello world app fails :S
Downloading https://github.com/roc-lang/basic-cli/releases/download/0.1.1/zAoiC9xtQPHywYk350_b7ust04BmWLW00sjb9ZPtSQk.tar.br
into /home/juliano/.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:3856:37
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
not sure what's the deal with cross-device. im on x86 linux building for x86 linux
unless somehow it's trying to link against a non-x86-linux platform??
i pushed what i got to https://github.com/omnibs/aoc22/, need to bail now! will keep trying later tonight but welcome any help/contributions!
@Juliano I hit this error today as well. I believe fs::rename
is erroring because from
and to
are on different filesystems: https://doc.rust-lang.org/std/fs/fn.rename.html#errors
I believe this is the cause: https://github.com/roc-lang/roc/blob/2a27d3c05f7974adf87e782704eab8d43c80652e/crates/packaging/src/cache.rs#L74
huh, interesting! I'm not sure what we want to do instead to make things work nicely with Nix here :thinking:
basically we want to download the package to a tempdir, then if it passes hash verification, mv
it to ~/.cache/roc
I guess we could detect that specific error and cp
instead in that case?
Yes, that's what I was thinking as well.
@Héctor Ramón if you already have it building from source locally, can you confirm if replacing the rename with a cp
fixes it?
im sloooowly trying to fix it with https://docs.rs/fs_extra/1.2.0/fs_extra/dir/fn.move_dir.html
Yeah, fs::copy
works only with files.
i got past that error but im getting
Error Os { code: 2, kind: NotFound, message: "No such file or directory" }
no idea where in the call stack
still hunting
so i randomly noticed i got a hello
executable after running cargo run hello.roc
on the first basic-cli example in the tutorial
and trying to run that executable i get bash: ./hello: No such file or directory
which may be where that error is coming from
$ ls -l hello
-rwxrwxr-x 1 juliano users 20419168 Dec 1 21:51 hello
$ file hello
hello: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=61e0eead3cc4b065c941ea6fdb611db808a3e389, for GNU/Linux 3.2.0, with debug_info, not stripped
i am on x86-64 linux, so im puzzled why this executable is not running
time for bed! my changes so far are in https://github.com/NoRedInk/roc/tree/fix-default-nix
oof, CrossesDevices
is only available on Nightly Rust
PR to fix it: https://github.com/roc-lang/roc/pull/4653
I just had it always try a deep copy if the rename fails for any reason
I went with copy rather than rename because I think it should be less work; either way it has to copy the files, this way it just doesn't have to delete them one by one from the source directory - which is a tempdir, so the OS can probably clean it up more quickly than that regardless
lmk if that branch works for you!
your branch works, but somehow it still produces an executable i can't run!
any errors?
@Folkert de Vries the "no such file or directory" above
ok, did we narrow down where that error originates?
which error? the no such file or directory? or the one richard patched?
the one richard patched we narrowed down and it seems fixed
the no such file, i've no idea what up :<
i read around the web no such file can happen when you have an incorrect arch executable, but it doesn't seem to be the case
right I'd like to get a backtrace for it. did you set the RUST_BACKTRACE
variable?
$ RUST_BACKTRACE=1 cargo run a.roc
Finished dev [unoptimized + debuginfo] target(s) in 0.16s
Running `target/debug/roc a.roc`
Error Os { code: 2, kind: NotFound, message: "No such file or directory" }
ah I see, the problem is in the platform, not in the compiler
you're using the cli platform?
yeah
so another weird data point, the nightly linux x86-64 is behaving the same for me
[nix-shell:~/git/roc]$ ./roc dev
bash: ./roc: No such file or directory
[nix-shell:~/git/roc]$ file roc
roc: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=489d7a87d7eadbd6804a2f3edacf8022e9a08ea5, for GNU/Linux 3.2.0, with debug_info, not stripped
[nix-shell:~/git/roc]$ ls -l roc
-rwxr-xr-x 1 juliano users 84308912 Dec 1 06:27 roc
can you try the rust_backtrace thing there?
it should print more, really
also what roc program are you running?
the first basic-cli example in the tutorial
sorry, try RUST_BACKTRACE=1 where this time?
the contents of a.roc:
app "hello"
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!"
on linux
oh, all of this is on linux
ok
well, that program should hit this piece of rust code
#[no_mangle]
pub extern "C" fn roc_fx_stdoutLine(line: &RocStr) {
let string = line.as_str();
println!("{}", string);
}
and nothing can really go wrong there, no file IO happens
hmm it must be in the compiler itself then
what i think is happening:
cargo run
compiles a.roc
into hello
the 2nd part is failing bc linux is refusing to run the executable itself, at all
i read around the web this can happen when you have an incorrect arch binary, but it doesn't seem to be the case
can you try just running the executable then, without invoking roc itself
yeah, that's what i did here, and i get:
bash: ./hello: No such file or directory
even tho it has execute permissions, is an ELF 64bit executable which matches my OS, etc
and the file is here?
yep
bizarre
yeah that is kind of wild
i get the same on the roc binary in the nightly
file is there, file roc
says all the right things, ldd roc
shows my nix store stuff, +x is there, but ./roc
gives me No such file or directory
$ file target/debug/roc
target/debug/roc: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /nix/store/ynn1by1qdl16q6qwwh2h7zkgrn36c6i8-glibc-2.35-163/lib/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, with debug_info, not stripped
$ file ~/Downloads/roc/roc
/home/juliano/Downloads/roc/roc: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=489d7a87d7eadbd6804a2f3edacf8022e9a08ea5, for GNU/Linux 3.2.0, with debug_info, not stripped
so the first one is the roc built by cargo, which is a valid executable on my system (i can launch it just fine, it just produces executables i can't launch)
the second is the nightly binary that my system refuses to run
differences:
ldd
on the nightly binary points ld-linux-x86-64.so.2
to the nix store tho, so this might be a red herringwhat is curious is the locally built roc binary works, but the stuff it produces, when the basic-cli platform is involved, won't launch
is it possible whatever is making the nightly binary an invalid executable on my system is also making any platform-specific binary styff in the platform invalid?
i can repro on the nightly binary in a cloud bastion from work, also running nixos 22.05
$ tar -zxvf roc_nightly-linux_x86_64-2022-12-01-d2d8511.tar.gz
...
$ ls -l roc
-rwxr-xr-x 1 juliano users 84308912 Dec 1 09:27 roc
$ file roc
roc: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=489d7a87d7eadbd6804a2f3edacf8022e9a08ea5, for GNU/Linux 3.2.0, with debug_info, not stripped
$ ./roc
bash: ./roc: No such file or directory
$ uname -a
Linux bastion 5.10.126 #1-NixOS SMP Mon Jun 27 07:41:01 UTC 2022 x86_64 GNU/Linux
Hi @Juliano, I'm also on NixOS 22.05. The linux nightly does not work on NixOS but you can clone the repo and run:
nix develop
cargo build --release
Once that is done you can use:
./target/release/roc ~/myRocProject/main.roc
I'll make sure to mention this workaround for NixOS in the documentation
@Anton thanks for confirming!
this also means we can't link to published platforms on NixOS, right?
if you try to compile a roc app with, say, packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.1.1/zAoiC9xtQPHywYk350_b7ust04BmWLW00sjb9ZPtSQk.tar.br" }
, the resulting binary will not run
Ah yes, I hadn't realized that yet but it makes sense.
I'll make a note to resolve that.
As a workaround; you can clone the basic-cli repo locally and use a path instead of a URL at pf:
.
thank you! that'll get me going :D
btw, for my own learning, do you know what makes these binaries incompatible with nixos?
I'd suspect libraries that are dynamically linked in the nightly roc binary.
Folks, I see we're not yet supporting MacOS 13 (Ventura) on the nightly releases so I decided to try and recompile Roc using nix from scratch (just to see how the current experience is going).
I'm running into these issues:
error: failed to run custom build command for `roc_builtins v0.0.1 (/Users/georgesboris/code/roc/roc/crates/compiler/builtins)`
Caused by:
process didn't exit successfully: `/Users/georgesboris/code/roc/roc/target/release/build/roc_builtins-a04181892e74d4fd/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-changed=build.rs
Compiling host ir to: /Users/georgesboris/code/roc/roc/crates/compiler/builtins/bitcode/builtins-host.ll
Compiling 64-bit bitcode to: /Users/georgesboris/code/roc/roc/crates/compiler/builtins/bitcode/builtins-host.bc
--- stderr
thread 'main' panicked at '"zig" "build" "ir" "-Drelease=true" failed with:
thread 155033 panic: Darwin is handled separately via std.zig.system.darwin module
Unable to dump stack trace: debug info stripped
', crates/compiler/builtins/build.rs:223:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `roc_builtins v0.0.1 (/Users/georgesboris/code/roc/roc/crates/compiler/builtins)`
Caused by:
process didn't exit successfully: `/Users/georgesboris/code/roc/roc/target/release/build/roc_builtins-a04181892e74d4fd/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-changed=build.rs
Compiling host ir to: /Users/georgesboris/code/roc/roc/crates/compiler/builtins/bitcode/builtins-host.ll
Compiling 64-bit bitcode to: /Users/georgesboris/code/roc/roc/crates/compiler/builtins/bitcode/builtins-host.bc
--- stderr
thread 'main' panicked at '"zig" "build" "ir" "-Drelease=true" failed with:
thread 155060 panic: Darwin is handled separately via std.zig.system.darwin module
Unable to dump stack trace: debug info stripped
', crates/compiler/builtins/build.rs:223:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
being a Rust (a Nix) noob - I wonder if there is a quickfix I'm missing? I've reinstalled nix and running nix develop
appears to work fine. Roc is freshly cloned.
I'm running on an Intel macbook pro, not using the "new" ARM stuff.
I don't think it is a rust issue. I think it is a zig version issue. We don't yet support zig 0.10.0 which I believe is required for macos 13
I could be wrong, but my understanding is that it can't work on macos 13 until we upgrade zig, which also requires updating llvm and inkwell, which is a larger task in general.
oh - so Roc is currently incompatible with macos 13 no matter what (and it will probably take a while before that changes)
that's correct?
That's my understanding. I think the current discussion was talking about targeting January for the change because this update could break things and we don't want to mess up advent of code.
yeah also llvm made a big breaking change, and the Rust library we use for llvm hasn't landed support for it quite yet: https://github.com/TheDan64/inkwell/pull/383 - that PR was approved at one point but hasn't gotten merged yet
I guess I'm gonna do AoC entirely in our web REPL :nerd:
Is the wasm repl up-to-date with nightly?
@Georges Boris I'm doing it in a docker container. https://github.com/michaelglass/advent-roc
I've been using a nightly macos 12 release on M1 with Ventura via nix
@Michael Glass ha! That will do! Thank you
Georges Boris said:
Is the wasm repl up-to-date with nightly?
Yes, it's deployed as part of the nightly build. But maybe docker is handier for you.
Last updated: Jul 06 2025 at 12:14 UTC