Stream: Nix toolbox devs & users

Topic: ✔ Running OCaml with str.cma


view this post on Zulip Arthur Azevedo de Amorim (Mar 09 2023 at 16:53):

I am having difficulties running OCaml with str.cma from the environment constructed by the toolbox. Specifically, I have created a configuration without any additional build inputs, and where I overrode Coq to 8.17+rc1. After running nix-shell, I tried running

$ ocaml str.cma

and I get the following error:

Cannot load required shared library dllcamlstr.
Reason: /home/arthur/.opam/coq-8.13/lib/ocaml/stublibs/dllcamlstr.so: /home/arthur/.opam/coq-8.13/lib/ocaml/stublibs/dllcamlstr.so: undefined symbol: caml_local_roots.

(I am a bit puzzled as to why it is trying to look into this OPAM directory... Shouldn't it avoid doing so when I enter the Nix shell?)

I am getting similar errors if I try to compile some file that uses str.cma and then try to execute it.

Any ideas on what could be going wrong here?

view this post on Zulip Théo Zimmermann (Mar 09 2023 at 20:38):

This is probably because OCaml is not in PATH.

view this post on Zulip Théo Zimmermann (Mar 09 2023 at 20:39):

Nix only puts in PATH / scope what you ask for explicitly.

view this post on Zulip Théo Zimmermann (Mar 09 2023 at 20:39):

I would have to learn more about how you define your environment to be able to help.

view this post on Zulip Arthur Azevedo de Amorim (Mar 09 2023 at 21:36):

I figured it out: I just had to invoke nix-shell with the --pure flag to avoid polluting its environment with flags set by OPAM.

view this post on Zulip Notification Bot (Mar 09 2023 at 21:36):

Arthur Azevedo de Amorim has marked this topic as resolved.


Last updated: Dec 05 2023 at 06:01 UTC