Stream: beginners

Topic: call roc bin from outside repo


view this post on Zulip Ghislain (Sep 25 2022 at 17:17):

Hi,
I build roc from source and I would like to be able to call the binary from outside the repo.
I tried with ln -s but other libs are missing:

➜ my-folder$ ls -l
total 8
-rw-r--r--  1 ghigt  staff   1,7K 25 sep 18:17 main.roc
lrwxr-xr-x  1 ghigt  staff    19B 25 sep 18:21 source -> ../source

➜  my-folder$ ./source/roc main.roc
🔨 Rebuilding platform...
thread 'main' panicked at 'Failed to find the lib directory. Did you copy the roc binary without also copying the lib directory?
If you built roc from source, the lib dir should be in target/release.
If not, the lib dir should be included in the release tar.gz file.', crates/compiler/builtins/src/bitcode.rs:9:45
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Though, it work the other way if I'm in the source folder and I call ./roc ../my-folder/main.roc.

What's the best way to do it properly?

view this post on Zulip Brendan Hansknecht (Sep 25 2022 at 17:40):

you need roc and the lib folder that lives next to it in target/release/

view this post on Zulip Brendan Hansknecht (Sep 25 2022 at 17:42):

for myself, I just alias roc=/.../roc/target/release/roc and alias roc-debug=/.../roc/target/debug/roc. Instead you could just copy roc/target/release/roc and roc/target/release/lib to /usr/local/bin for example. Or somewhere else and add it to the path.

view this post on Zulip Richard Feldman (Sep 25 2022 at 17:54):

this is a temporary state of affairs - the goal is to make the binaries roc produces not need any external dependencies like this, but right now they do because there are some features we haven't finished yet to make that work

view this post on Zulip Ghislain (Sep 25 2022 at 19:03):

Brendan Hansknecht said:

for myself, I just alias roc=/.../roc/target/release/roc and alias roc-debug=/.../roc/target/debug/roc. Instead you could just copy roc/target/release/roc and roc/target/release/lib to /usr/local/bin for example. Or somewhere else and add it to the path.

my problem with this solution is to include the platform from the source directory, do you link it (with ln -s) or put the full path in your .roc file (or something else)?

view this post on Zulip Brendan Hansknecht (Sep 25 2022 at 19:16):

Ah, for platforms, it depends. A lot of the time I just copy them over because they are small and I might change my local copy.

Otherwise, it should be fine to link the platform directory and use a relative path.

view this post on Zulip Brendan Hansknecht (Sep 25 2022 at 19:17):

So I worry about platforms separately from dealing with the lib folder.

view this post on Zulip Brendan Hansknecht (Sep 25 2022 at 19:18):

Sometimes I just use a relative path overall cause I tend to keep roc related repos in a folder adjacent to the roc repo folder

view this post on Zulip Notification Bot (Sep 25 2022 at 19:34):

Ghislain has marked this topic as resolved.

view this post on Zulip Notification Bot (Sep 25 2022 at 19:34):

Ghislain has marked this topic as unresolved.

view this post on Zulip Ghislain (Sep 25 2022 at 19:35):

Sorry for the bot, don't know if I need to check it or not, it looks not usually used.
Thank you for your answers.

view this post on Zulip jan kili (Sep 25 2022 at 20:44):

I think the "resolved" feature is useful for specific question threads like this one!

view this post on Zulip jan kili (Sep 25 2022 at 20:44):

Also FWIW for my apps I use a git submodule of the Roc repo to use example platform source - not necessarily the best way, but it's worked for me

view this post on Zulip Ghislain (Sep 25 2022 at 21:00):

Cool, I saw one of your repo and didn't know how you did your "git thing" :sweat_smile:

view this post on Zulip jan kili (Sep 25 2022 at 21:28):

:sparkles:magic:sparkles:

view this post on Zulip jan kili (Sep 25 2022 at 21:28):

It's basically a subclone

view this post on Zulip Brendan Hansknecht (Sep 25 2022 at 22:41):

I would do git submodules, but i don't want like 20 copies of the roc repo on my machine


Last updated: Jul 06 2025 at 12:14 UTC