Hi everyone, I'm using the latest nightly build of Roc:
❱ roc --version
roc nightly pre-release, built from commit 28146c9 on Mo 24 Apr 2023 09:08:22 UTC
And I have a MWE project with these files:
src/main.roc
package "Example"
exposes [HelloWorld]
packages {}
src/HelloWorld.roc
interface HelloWorld exposes [greet] imports []
greet = \person -> "Hello, \(person)."
expect greet "World" == "Hello, World."
When I run Roc test like this:
❱ roc test src/main.roc
I get this error:
ld: cannot find -lc
ld: cannot find -lm
ld: cannot find -lpthread
ld: cannot find -ldl
ld: cannot find -lrt
ld: cannot find -lutil
ld: cannot find -lc_nonshared
thread 'main' panicked at '
___________
Linking command failed with status ExitStatus(unix_wait_status(256)):
Child { stdin: None, stdout: None, stderr: None, .. }
___________
', crates/compiler/build/src/link.rs:1392:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Might be related, but I am pretty sure there is a bug when you try and run roc cli in the same directory as a package file.
This is why I usually create packages in a /package
folder i.e. /package/main.roc
and then when I run it I use roc test ./package/Example
I've just tried running
roc test example/src/main.roc
and I got the same error :/
Otherwise I don't see any issues with your code. It may be a compiler issue.
I don't know if you can run roc test
on a package file, can you try it on the interface directly?
There is an open issue for roc test
to find and test all modules in a package.
I'll add that I'm on Ubuntu 23.04, but I was also getting this error on Ubuntu 22.10 last week as well, so I don't think it's specific to this version of Ubuntu.
Just tried
roc test src/HelloWorld.roc
and got the same error again
Screen-Shot-2023-04-25-at-15.29.30.png
% roc test package/HelloWorld.roc
0 failed and 1 passed in 657 ms.
Looks like a compiler issue. Not sure I can help you much further.
Thanks for your suggestions, I'll try some other stuff and report back :)
If you can build from source, using e.g. nix develop
then cargo run --release --locked
and using roc in /targets/release etc that might be the.most reliable
Ah, so I compiled roc from source in nix develop
and roc test
ran fine, then I moved it to my path and ran it and it worked, then I downloaded the nightly build and ran it inside the nix shell and it still worked, but none of these worked outside the nix shell! Seems to be something specific to my setup, no idea what it could be though :shrug:
I do think it is caused by changes in Ubuntu 23.04, can you make an issue for this @Hannes?
Sure, I'll also try and recreate the bug in a clean Ubuntu VM with a few different versions and add that to the issue
I've created issue #5340 for this and I've confirmed that it works on Ubuntu 22.04 but not on 23.04 as @Anton suspected.
Thanks for checking this @Hannes, does roc run src/main.roc
work on 23.04?
It works in that it doesn't crash, but I get the "could not find platform" error, which makes sense because it's a library.
Oh yes, that makes sense, it's an interface, I looked over that. Does the hello world app work on 23.04?
Yes, I haven't had that error with building/running apps, but when I put the expect
in a hello world app and run roc test
I get the same crash:
app "hello-world"
packages {
pf: "https://github.com/roc-lang/basic-cli/releases/download/0.3.1/97mY3sUwo433-pcnEQUlMhn-sWiIf_J9bPhcAFZoqY4.tar.br",
}
imports [pf.Stdout]
provides [main] to pf
greet = \person -> "Hello, \(person)!"
expect greet "World" == "Hello, World."
main = Stdout.line (greet "World")
❱ roc test hello-world.roc
ld: cannot find -lc
ld: cannot find -lm
ld: cannot find -lpthread
ld: cannot find -ldl
ld: cannot find -lrt
ld: cannot find -lutil
ld: cannot find -lc_nonshared
thread 'main' panicked at '
___________
Linking command failed with status ExitStatus(unix_wait_status(256)):
Child { stdin: None, stdout: None, stderr: None, .. }
___________
', crates/compiler/build/src/link.rs:1396:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Can you try roc run --linker=legacy {some app}
?
Running the hello-world app with the legacy linker gives this crash:
❱ roc run --linker=legacy hello-world.roc
ld: cannot find -lc
ld: cannot find -lm
ld: cannot find -lpthread
ld: cannot find -ldl
ld: cannot find -lrt
ld: cannot find -lutil
ld: cannot find -lc_nonshared
thread 'main' panicked at 'not yet implemented: gracefully handle `ld` (or `zig` in the case of wasm with --optimize) returning exit code Some(1)', crates/compiler/build/src/program.rs:1004:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
cool. That is what I wanted to check, just to verify.
Can you make sure you have build-essential
installed and test again? That should at least fix -lc
, but I would expect ubuntu to have headers for libc install by default, so idk.
I'm getting
build-essential is already at the latest version 12.9ubuntu3
hmm..ok
These should all be installed libraries by default on most linux systems. On top of that, we are just calling the system ld
here, so it should be able to find them. build-essential
definitely installs the stuff for libc dev. Really weird.
Okaaayyyyyyy, I've figured out why it wasn't working, turns out I had another version of GNU binutils installed which had presedence over the system package, and once I removed that directory from my PATH
it works fine now! Thanks everyone who looked into this, I'll close the issue as well.
Hannes has marked this topic as resolved.
Last updated: Jul 06 2025 at 12:14 UTC