Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting OCAMLFIND_DESTDIR can mess with opam installation #136

Open
Alizter opened this issue Mar 8, 2023 · 5 comments
Open

Setting OCAMLFIND_DESTDIR can mess with opam installation #136

Alizter opened this issue Mar 8, 2023 · 5 comments

Comments

@Alizter
Copy link

Alizter commented Mar 8, 2023

I'm not sure if this is the correct place to report this, but when installing zarith via opam and OCAMLFIND_DESTDIR has been set (i.e. because of a Nix shell) then opam will inherit the env var which causes the build to fail. This can obviously be worked around by unsetting the env var, but it might be worth reporting it here with the workaround in case anybody else comes across the issue.

@xavierleroy
Copy link
Contributor

From your description, it sounds like a problem that can affect all packages that use ocamlfind for installation, not just Zarith. Yet, a Web search finds only this occurrence in 2012: ocaml/opam#164 . They claimed they "fixed" the issue by displaying a warning. Did you see a warning?

@avsm
Copy link
Member

avsm commented Mar 9, 2023

@Alizter what's the actual build failure you're seeing under Nix? It'll help diagnose the issue.

@Alizter
Copy link
Author

Alizter commented Mar 9, 2023

Here is what opam spits out:

[ERROR] The installation of zarith failed at "make install".

#=== ERROR while installing zarith.1.12 =======================================#
# context     2.1.4 | linux/x86_64 | conf-gmp.4 | https://opam.ocaml.org#dd770689
# path        ~/.opam/conf-gmp.4/.opam-switch/build/zarith.1.12
# command     ~/.opam/opam-init/hooks/sandbox.sh install make install
# exit-code   2
# env-file    ~/.opam/log/zarith-599688-80a46f.env
# output-file ~/.opam/log/zarith-599688-80a46f.out
### output ###
# ocamlfind install -destdir "/home/ali/outputs/out/lib/ocaml/4.14.1/site-lib/" zarith META zarith.cma libzarith.a z.cmi q.cmi big_int_Z.cmi zarith_top.cma z.mli zarith.cmxa z.cmx q.cmx big_int_Z.cmx zarith.cmxs zarith.h q.mli big_int_Z.mli zarith.a z.cmti q.cmti big_int_Z.cmti -optional dllzarith.so
# ocamlfind: Bad configuration: Cannot mkdir /home/ali/outputs/out/lib/ocaml/4.14.1/site-lib/zarith because a path component does not exist or is not a directory
# make: *** [project.mak:115: install] Error 2

Something in Nix set OCAMLFIND_DESTDIR probably the Coq derivation. I have this value:

/home/ali/outputs/out/lib/ocaml/4.14.1/site-lib/

unsetting this env var lets the opam command succeed.

Here is the out file for the opam build:

ocamlfind install -destdir "/home/ali/outputs/out/lib/ocaml/4.14.1/site-lib/" zarith META zarith.cma libzarith.a z.cmi q.cmi big_int_Z.cmi zarith_top.cma z.mli zarith.cmxa z.cmx q.cmx big_int_Z.cmx zarith.cmxs zarith.h q.mli big_int_Z.mli zarith.a z.cmti q.cmti big_int_Z.cmti -optional dllzarith.so
ocamlfind: Bad configuration: Cannot mkdir /home/ali/outputs/out/lib/ocaml/4.14.1/site-lib/zarith because a path component does not exist or is not a directory
make: *** [project.mak:115: install] Error 2

@Alizter
Copy link
Author

Alizter commented Mar 9, 2023

This issue is not super cirtical for me since I am doing something very nonstandard. Normal users will never touch that env var. I was attempting to quickly set up some opam switches for testing the interaction of opam and Dune. When I actually need different versions of packages I just use Nix anyway.

@rounakdatta
Copy link

unsetting this env var lets the opam command succeed.
Thank you!! I've been trying to install ppx_jane under a nix develop environment, and came across this thorny issue. Unsetting the variable indeed solved the issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants