Install OPAM 1 package via OPAM 2?

I’ve updated to OPAM 2, and I’m having issues installing some packages. In particular, when trying to install javalib.2.3.5 on OPAM 2.0.0 on a 4.07.0 switch I get the following:

# command     ~/.opam/opam-init/hooks/sandbox.sh build make installptrees
...
# ocamlfind: Cannot mkdir /Users/ins/.opam/4.07.0/lib/ptrees: Operation not permitted

My guess is that this is due to the new sandboxing feature that was introduced. Is there a way to say “I trust this package, install it as you would have in OPAM 1.2.x?”

I’ve seen conflicting reports about backwards compatibility. For example, here it says:

All packages installing in opam 1.2.2 should exist and install fine on 2.0.0~rc4 (if you find one that doesn’t, please report!)

But i’ve also seen plenty of GitHub issues with issues similar to mine.

Thanks so much!

I found this, which provides an escape hatch for the sandboxing system, however opam init --disable-sandboxing didn’t solve my issue.

So, either (1) opam init --disable-sandboxing didn’t actually disable sandboxing or (2) I’m getting Operation not permitted for some other reason.

Okay, solved the issue by removing:

wrap-build-commands:
  ["%{hooks}%/sandbox.sh" "build"] {os = "linux" | os = "macos"}
wrap-install-commands:
  ["%{hooks}%/sandbox.sh" "install"] {os = "linux" | os = "macos"}
wrap-remove-commands:
  ["%{hooks}%/sandbox.sh" "remove"] {os = "linux" | os = "macos"}

from ~/.opam/config, installing my packages, and then sticking them back in.

I’ll post an issue on the opam GitHub to report that --disable-sandboxing doesn’t correctly update config when used on an already initialized opam.

Here, the package definition is not sandboxing compatible: during build steps, it tries to install library but sandboxing doesn’t allow write access to certain opam root folders, while install does (e.g lib, bin… in opam root). When build and install command are well separated, sandboxing isn’t blocking.

Disabling sandboxing is not a single-operation. Ensure to re-enable it afterwards, disasters do happen.

Once you have an opam initialised, you need to give the --reinit to relaunch initialisation, especially for scripts.

Thanks for following up!

I’ve posted an issue on the javalib issue tracker, requesting that they update their package.

I’ve re-enabled sandboxing now, and will continue to encourage package maintainers to update their packages to support sandboxing.

I realized I forgot a --reinit afterwards, but unfortunately even opam init --reinit --disable-sandboxing didn’t work. I’ve added a follow-up to my GitHub issue.

Thanks again for the detailed response!

1 Like

Javalib 3.0 is now available and this problem is solved.
Ptrees are now part of Javalib_pack.

1 Like