I'm not setting environment variables by hand. All the correct ocaml env vars should be setup by opam since I am creating a brand new switch. In order to use opam, you need a global install of ocaml. I get opam and ocaml from nixpkgs which is why there are some funny env vars like OCAMLFIND_DESTDIR. Even if these are unset, opam fails to build coq-stdlib due to the way plugins are detected. The fact that I am on NixOS shouldn't really be relevent here as it shouldn't impede the functionality of opam which all happens inside a .opam folder anyway.
My guess I have another lingering env var related to findlib which is preventing findlib in Coq from finding the plugins correctly. Not sure what it is.
if you install just coq-core does ocamlfind find the plugins?
OK I found the issue.
I had OCAMLPATH set before doing opam switch create
I thought that opam sandboxed these env vars especiallly ones that it actually uses but apparently not.
I guess we should document somewhere that coq-stdlib cannot be installed if OCAMLPATH has been set externally. Or at least coq-core should be installed and then
eval $(opam env) done and then the stdlib.
Ali Caglayan has marked this topic as resolved.
I'll open a PR
Yes, I was going to say "I bet your OCAMLPATH is funny due to Nix"
because that failure is indeed coq-stdlib not finding where the Coq OCaml libs are, and all that the build script does is to call ocamlfind
Is there a way for opam to not use the externally given evn var?
Maybe ask on #opam 's Slack?
AFAICT, you do not need a global OCaml install to use opam. I have opam installed on NixOS but not OCaml and it works (as long as I do
nix-shell -p binutils before creating a new switch, which will build an OCaml compiler anyway).
I can confirm you don't need one; the only downside is that each opam switch will rebuild the compiler, but that takes a couple minutes
Last updated: Nov 29 2023 at 21:01 UTC