tarides / ocaml-platform-installer

The best way for developers to write software in OCaml
ISC License
61 stars 8 forks source link

Installation failed when used in an empty debian VM #78

Open TheLortex opened 2 years ago

TheLortex commented 2 years ago

I'm trying to easily install the platform in a debian Github Codespace (https://github.com/features/codespaces). The platform installer is not working as expected. When running it, it fails with the following error message:

@TheLortex ➜ /workspaces/ocaml-codespace (main) $ sudo bash < <(curl -L https://github.com/tarides/ocaml-platform-installer/releases/latest/download/installer.sh)
[...] 
=> Install into /usr/local/bin
Installation is done. Please run 'ocaml-platform' to install the Platform tools inside your set switch.
@TheLortex ➜ /workspaces/ocaml-codespace (main) $ ocaml-platform
ocaml-platform: [ERROR] Command 'opam show ocaml -f installed-version --normalise --yes -q
           --color=never --root /home/codespace/.opam' failed: exited with 50

When running the opam command manually I get [ERROR] Opam has not been initialised, please run 'opam init'

Julow commented 2 years ago

The root cause is an error during opam init, which is not reported properly: https://github.com/tarides/ocaml-platform-installer/pull/79

With this patch, I now get:

ocaml-platform: [DEBUG] Running: 'opam' 'init' '--yes' '-q' '--color=never' '--root' '/root/.opam'
ocaml-platform: [DEBUG] Error in execution: 
# bwrap: Creating new namespace failed: Operation not permitted
### output ###
# output-file          /tmp/opam-xxx-11/ocaml-system-11-8b8a2d.out
# env-file             /tmp/opam-xxx-11/ocaml-system-11-8b8a2d.env
# exit-code            1
# command              ~/.opam/opam-init/hooks/sandbox.sh build ocaml gen_ocaml_config.ml
# path                 ~/.opam/default/.opam-switch/build/ocaml-system.4.11.1
# context              2.0.8 | linux/x86_64 |  | https://opam.ocaml.org#6447b747
#=== ERROR while compiling ocaml-system.4.11.1 ================================#

[ERROR] The compilation of ocaml-system failed at "/root/.opam/opam-init/hooks/sandbox.sh build ocaml gen_ocaml_config.ml".
[NOTE] Will configure from built-in defaults.
[WARNING] Running as root is not recommended
ocaml-platform: [ERROR] Command 'opam init --yes -q --color=never --root /root/.opam' failed: exited with 31

As a workaround for now, you can init opam manually with opam init --disable-sandboxing and run ocaml-platform again.