Opam permissions on Manjaro

Reading time ~1 minute

bwrap: No permissions to creating new namespace

When installing ounit, I faced the following issue:

$ opam install ounit
[NOTE] It seems you have not updated your repositories for a while. Consider updating them with:
       opam update

The following actions will be performed:
  ∗ install stdlib-shims 0.1.0 [required by ounit]
  ∗ install ounit        2.1.2
===== ∗ 2 =====
Do you want to continue? [Y/n] Y

A while later:

#=== ERROR while compiling stdlib-shims.0.1.0 =================================#
# context     2.0.5 | linux/x86_64 | ocaml-base-compiler.4.08.0 | https://opam.ocaml.org#225ac83b
# path        ~/.opam/408/.opam-switch/build/stdlib-shims.0.1.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p stdlib-shims -j 3
# exit-code   1
# env-file    ~/.opam/log/stdlib-shims-11129-ad8886.env
# output-file ~/.opam/log/stdlib-shims-11129-ad8886.out
### output ###
# bwrap: No permissions to creating new namespace, likely because the kernel does not allow non-privileged user namespaces. On e.g. debian this can be enabled with 'sysctl kernel.unprivileged_userns_clone=1'.

So, it cannot create the new namespaces… One could be tempted to run it with sudo. But this is not good. Not good at all (see the last section). Instead, you have to enable non privileged user namespaces.

The solution

Simply run:

$ sudo sysctl kernel.unprivileged_userns_clone=1

Which will enable non privileged user namespaces. And now the install should just be fine.

$ opam install ounit
[NOTE] It seems you have not updated your repositories for a while. Consider updating them with:
       opam update

The following actions will be performed:
  ∗ install stdlib-shims 0.1.0 [required by ounit]
  ∗ install ounit        2.1.2
===== ∗ 2 =====
Do you want to continue? [Y/n] Y

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ounit.2.1.2] found in cache
[stdlib-shims.0.1.0] found in cache

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
∗ installed stdlib-shims.0.1.0
∗ installed ounit.2.1.2
Done.

Why not using sudo ?

One could be tempted to…

$ sudo opam install ounit

I did it in the first place. It worked “fine”. Running it a second time:

[WARNING] Running as root is not recommended
[NOTE] Package ounit is already installed (current version is 2.2.1).

So, I have the package. But, when I tried testing my program:

$ ./runTests.sh 
+ ocamlfind ocamldep -package oUnit2 -modules tests/randomVariableGausianTest.ml > tests/randomVariableGausianTest.ml.depends
ocamlfind: Package `oUnit2' not found

Weird… I have the package, but for some reason it remains not found…

Then, running sudo opam list and opam list I obtained different lists of packages. I guess the packages installed with sudo are not installed at the right place (and therefore, cannot be called by the compiler by default).

OCaml List rev_map vs map

If you found this page, you are probably very familiar with OCaml already!So, OCaml has a ````map```` function whose purpose is pretty cl...… Continue reading

How to optimize PyTorch code ?

Published on March 17, 2024

Acronyms of deep learning

Published on March 10, 2024