tarides / ocaml-platform-installer

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

Handle missing system compilers #85

Closed patricoferris closed 2 years ago

patricoferris commented 2 years ago

Hello, thanks for this great tool!

I recently took it for a spin with a 5.0.0~alpha1 switch and it seems things go a little askew when looking for a system compiler. The context of this was building in a dockerfile.

FROM ocaml/opam:debian-11-ocaml-5.0@sha256:8ef27313193b5e003fce1c79624f1b5796508c672abdc6c2d24b4698ad92f398
RUN curl -sL https://github.com/tarides/ocaml-platform-installer/releases/latest/download/installer.sh > ./installer.sh
RUN chmod +x installer.sh
RUN sudo bash ./installer.sh

And then running ocaml-platform -v -v which resulted in the following.

opam@de7fead58b3f:~/workshop$ ocaml-platform -v -v 
ocaml-platform: [DEBUG] Running: 'opam' 'show' 'ocaml' '-f' 'installed-version' '--normalise' '--yes' '-q' '--color=never' '--root' '/home/opam/.opam'
* Inferring tools version...
ocaml-platform: [DEBUG] Running: 'opam' 'show' 'dune' 'dune-release' 'merlin' 'ocaml-lsp-server' 'odoc' 'ocamlformat' '-f' 'name,installed-version' '--normalise' '--yes' '-q' '--color=never' '--root' '/home/opam/.opam'
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'available-versions' 'dune' '--yes' '-q' '--color=never' '--root' '/home/opam/.opam'
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'depends:' 'dune.3.4.1' '--yes' '-q' '--color=never' '--root' '/home/opam/.opam'
  -> dune will be installed as dune.3.4.1-ocaml5.0.0
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'available-versions' 'dune-release' '--yes' '-q' '--color=never' '--root' '/home/opam/.opam'
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'depends:' 'dune-release.1.6.2' '--yes' '-q' '--color=never' '--root' '/home/opam/.opam'
  -> dune-release will be installed as dune-release+bin+platform.1.6.2-ocaml5.0.0
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'available-versions' 'merlin' '--yes' '-q' '--color=never' '--root' '/home/opam/.opam'
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'depends:' 'merlin.4.6.1~5.0preview' '--yes' '-q' '--color=never' '--root' '/home/opam/.opam'
  -> merlin will be installed as merlin+bin+platform.4.6.1~5.0preview-ocaml5.0.0
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'available-versions' 'ocaml-lsp-server' '--yes' '-q' '--color=never' '--root' '/home/opam/.opam'
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'depends:' 'ocaml-lsp-server.1.13.2~5.0preview' '--yes' '-q' '--color=never' '--root' '/home/opam/.opam'
  -> ocaml-lsp-server will be installed as ocaml-lsp-server+bin+platform.1.13.2~5.0preview-ocaml5.0.0
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'available-versions' 'odoc' '--yes' '-q' '--color=never' '--root' '/home/opam/.opam'
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'depends:' 'odoc.2.1.1' '--yes' '-q' '--color=never' '--root' '/home/opam/.opam'
  -> odoc will be installed as odoc+bin+platform.2.1.1-ocaml5.0.0
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'available-versions' 'ocamlformat' '--yes' '-q' '--color=never' '--root' '/home/opam/.opam'
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'depends:' 'ocamlformat.0.24.1' '--yes' '-q' '--color=never' '--root' '/home/opam/.opam'
  -> ocamlformat will be installed as ocamlformat+bin+platform.0.24.1-ocaml5.0.0
* Building the tools...
  -> Creating a sandbox...
ocaml-platform: [DEBUG] Running: 'opam' 'config' 'var' 'prefix' '--yes' '-q' '--color=never' '--root' '/home/opam/.opam'
ocaml-platform: [DEBUG] Error in execution: [WARNING] var was deprecated in version 2.1 of the opam CLI. Use opam var instead or set OPAMCLI environment variable to 2.0.
ocaml-platform: [INFO] Creating sandbox switch for building the tools
ocaml-platform: [DEBUG] Running: 'opam' 'switch' 'create' '--no-switch' '/tmp/ocaml-platform-sandbox-cba4ba' '--empty' '--yes' '-q' '--color=never' '--root' '/home/opam/.opam'
ocaml-platform: [DEBUG] Running: 'opam' 'config' 'var' 'sys-ocaml-version' '--yes' '-q' '--color=never' '--root' '/home/opam/.opam'
ocaml-platform: [DEBUG] Error in execution: [ERROR] Variable sys-ocaml-version not found in global config
[WARNING] var was deprecated in version 2.1 of the opam CLI. Use opam var instead or set OPAMCLI environment variable to 2.0.
ocaml-platform: [DEBUG] Running: 'opam' 'config' 'set-global' 'sys-ocaml-version' '5.0.0' '--yes' '-q' '--color=never' '--root' '/home/opam/.opam'
ocaml-platform: [DEBUG] Error in execution: [WARNING] set-global was deprecated in version 2.1 of the opam CLI. Use opam var instead or set OPAMCLI environment variable to 2.0.
ocaml-platform: [DEBUG] Running: 'opam' 'install' 'ocaml-system' '--yes' '-q' '--color=never' '--switch' '/tmp/ocaml-platform-sandbox-cba4ba' '--root' '/home/opam/.opam'
ocaml-platform: [DEBUG] Error in execution: [ERROR] ocaml-system unmet availability conditions, e.g. 'sys-ocaml-version = "4.14.0"'
ocaml-platform: [DEBUG] Running: 'opam' 'config' 'unset-global' 'sys-ocaml-version' '--yes' '-q' '--color=never' '--root' '/home/opam/.opam'
ocaml-platform: [DEBUG] Error in execution: [WARNING] unset-global was deprecated in version 2.1 of the opam CLI. Use opam var instead or set OPAMCLI environment variable to 2.0.
ocaml-platform: [ERROR] Command 'opam install ocaml-system --yes -q --color=never --switch
           /tmp/ocaml-platform-sandbox-cba4ba --root /home/opam/.opam' failed: exited with 5

Looks like (although I'm not familiar with the internals) it tries to install a 5.0.0 system compiler and fails as there is none at the moment. A pretty niche bug, but perhaps it would be good to catch and report this error. At the moment it looks like it fails silently and then goes on to try and do something with the switch that was never made and only then realises something has gone wrong.

panglesd commented 2 years ago

Thanks a lot @patricoferris for the report! Yes, this is a known bug (and not that niche, if people try ocaml5 with it before its official release!). But there is already a PR for that: #83! Hopefully, this will solve the problem.

tmattio commented 2 years ago

The PR above should have solved the issue, so I'm closing it for now, but feel free to re-open it if you still have a problem.

Thanks again for the report!