Reputation: 25657
Is it possible to move the OPAM root? Or, to create a "portable" (in the sense of e.g. "firefox portable") version of an OPAM root?
That is, install a bunch of packages via opam --root=/PATH/TO/A
, then move /PATH/TO/A
to /ANOTHER/PATH/TO/B
, and run everything from there.
A naive try led to a small error in "opam config env", where the old path slipped through. Also, some config files (findlib, global-config) had to be adjusted. After fixing that, some stuff worked, but "utop" fails with
Fatal error: exception Not_found
Is this a principle issue, or is a portable OPAM root just a matter of setting the right environment variables after the move?
Upvotes: 1
Views: 418
Reputation: 6697
Compiler itself is almost portable, a matter of setting environment variables OCAMLLIB
and CAML_LD_LIBRARY_PATH
, the remaining problem is running bytecode executables which embed path to ocamlrun, see https://caml.inria.fr/mantis/view.php?id=5950 for details.
As for the packages - there is no universal guarantee, it all depends on what package does during the build. Majority of "normal" libraries that don't expect to find some data files at run time should work though. As comments above suggest, it is often faster to take snapshot of opam state (bundle) and rebuild in different path.
Upvotes: 0