tarides / ocaml-platform-installer

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

Error when using the Platform Installer on Debian #156

Open e10e3 opened 1 year ago

e10e3 commented 1 year ago

Hello, I encountered an error when using the Platform Installer.

I am using Debian 11. I installed Opam with the distribution's package, then tried using the Platform Installer.

After successfully executing install-platform.sh, running ocaml-platform yielded this output:

* Initialising Opam before the first use, this might take some time...
Initting repo
* Inferring tools version...
  -> dune.3.7.1 will be built from source
  -> dune-release.1.6.2 will be built from source
  -> merlin.4.8-500 will be built from source
  -> ocaml-lsp-server.1.15.1-5.0 will be built from source
  -> odoc.2.2.0 will be built from source
  -> ocamlformat.0.25.1 will be built from source
* Building the tools...
  -> Creating a sandbox...
  -> [1/6] Building ocamlformat...
  -> [2/6] Building odoc...
  -> [3/6] Building ocaml-lsp-server...
  -> [4/6] Building merlin...
  -> [5/6] Building dune-release...
  -> [6/6] Building dune...
* Installing tools...
ocaml-platform: [ERROR] Command 'opam install dune.3.7.1-ocaml5.0.0+platform
           dune-release.1.6.2+platform merlin.4.8-500-ocaml5.0.0+platform
           ocaml-lsp-server.1.15.1-5.0-ocaml5.0.0+platform
           odoc.2.2.0-ocaml5.0.0+platform ocamlformat.0.25.1+platform --yes
           -q --color=never --root /home/<user>/.opam' failed: exited with 40

Please let me know if you need further information.

Julow commented 1 year ago

What is your version of Opam ? (opam --version) Can you try running the same command again ?

e10e3 commented 1 year ago

My version of Opam is 2.0.8.

Running ocaml-platform again gives me the same error, but without the building step:

Initting repo
* Inferring tools version...
  -> dune.3.7.1 will be installed from cache
  -> dune-release.1.6.2 will be installed from cache
  -> merlin.4.8-500 will be installed from cache
  -> ocaml-lsp-server.1.15.1-5.0 will be installed from cache
  -> odoc.2.2.0 will be installed from cache
  -> ocamlformat.0.25.1 will be installed from cache
* Installing tools...
ocaml-platform: [ERROR] Command 'opam install ocamlformat.0.25.1+platform
           odoc.2.2.0-ocaml5.0.0+platform
           ocaml-lsp-server.1.15.1-5.0-ocaml5.0.0+platform
           merlin.4.8-500-ocaml5.0.0+platform dune-release.1.6.2+platform
           dune.3.7.1-ocaml5.0.0+platform --yes -q --color=never --root
           /home/<user>/.opam' failed: exited with 40
panglesd commented 1 year ago

Hello and thanks for the report!

ocaml-platform calls opam at some point to install packages, which in your case exits with error 40: from opam's man page:

       40  Sync error. Could not fetch some remotes from the network. This can
           be a partial error.

It is quite strange, since the packages are on a local opam repository (on your machine), so network should not be involved.

Could you paste the output of ocaml-platform -vv? Could you also paste the output of opam repository to check that the local repository is enabled on your switch? (And, just in case, what is your ocaml-platform --version?)

e10e3 commented 1 year ago

I'm using ocaml-platform in version 0.8.0.

This is the verbose output of the command, obtained with ocaml-platform -vv:

ocaml-platform: [DEBUG] Running: 'opam' 'list' '--field-match=conflict-class:ocaml-core-compiler' '--installed' '--short' '--yes' '-q' '--color=never' '--root' '/home/<user>/.opam'
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'version' 'ocaml-base-compiler' '--yes' '-q' '--color=never' '--root' '/home/<user>/.opam'
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'pin' 'ocaml-base-compiler' '--yes' '-q' '--color=never' '--root' '/home/<user>/.opam'
Initting repo
* 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/<user>/.opam'
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'available-versions' 'dune' '--yes' '-q' '--color=never' '--root' '/home/<user>/.opam'
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'depends:' 'dune.3.7.1' '--yes' '-q' '--color=never' '--root' '/home/<user>/.opam'
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'available-versions' 'dune-release' '--yes' '-q' '--color=never' '--root' '/home/<user>/.opam'
  -> dune.3.7.1 will be installed from cache
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'depends:' 'dune-release.1.6.2' '--yes' '-q' '--color=never' '--root' '/home/<user>/.opam'
  -> dune-release.1.6.2 will be installed from cache
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'available-versions' 'merlin' '--yes' '-q' '--color=never' '--root' '/home/<user>/.opam'
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'depends:' 'merlin.4.8-500' '--yes' '-q' '--color=never' '--root' '/home/<user>/.opam'
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'available-versions' 'ocaml-lsp-server' '--yes' '-q' '--color=never' '--root' '/home/<user>/.opam'
  -> merlin.4.8-500 will be installed from cache
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'depends:' 'ocaml-lsp-server.1.15.1-5.0' '--yes' '-q' '--color=never' '--root' '/home/<user>/.opam'
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'available-versions' 'odoc' '--yes' '-q' '--color=never' '--root' '/home/<user>/.opam'
  -> ocaml-lsp-server.1.15.1-5.0 will be installed from cache
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'depends:' 'odoc.2.2.0' '--yes' '-q' '--color=never' '--root' '/home/<user>/.opam'
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'available-versions' 'ocamlformat' '--yes' '-q' '--color=never' '--root' '/home/<user>/.opam'
  -> odoc.2.2.0 will be installed from cache
ocaml-platform: [DEBUG] Running: 'opam' 'show' '-f' 'depends:' 'ocamlformat.0.25.1' '--yes' '-q' '--color=never' '--root' '/home/<user>/.opam'
ocaml-platform: [DEBUG] Running: 'opam' 'repository' 'add' '--this-switch' '-k' 'local' 'platform-cache' '/home/<user>/.opam/plugins/ocaml-platform/cache/repo' '--yes' '-q' '--color=never' '--root' '/home/<user>/.opam'
  -> ocamlformat.0.25.1 will be installed from cache
* Installing tools...
ocaml-platform: [INFO] Error in 'opam' 'repository' 'add' '--this-switch' '-k' 'local' 'platform-cache' '/home/<user>/.opam/plugins/ocaml-platform/cache/repo' '--yes' '-q' '--color=never' '--root' '/home/<user>/.opam':
[NOTE] Repository platform-cache has been added to the selections of switch default only.
       Run `opam repository add platform-cache --all-switches|--set-default' to use it in all existing switches, or in newly created switches, respectively.

ocaml-platform: [DEBUG] Running: 'opam' 'update' '--no-auto-upgrade' 'platform-cache' '--yes' '-q' '--color=never' '--root' '/home/<user>/.opam'
ocaml-platform: [DEBUG] Running: 'opam' 'install' 'ocamlformat.0.25.1+platform' 'odoc.2.2.0-ocaml5.0.0+platform' 'ocaml-lsp-server.1.15.1-5.0-ocaml5.0.0+platform' 'merlin.4.8-500-ocaml5.0.0+platform' 'dune-release.1.6.2+platform' 'dune.3.7.1-ocaml5.0.0+platform' '--yes' '-q' '--color=never' '--root' '/home/<user>/.opam'
ocaml-platform: [INFO] Error in 'opam' 'install' 'ocamlformat.0.25.1+platform' 'odoc.2.2.0-ocaml5.0.0+platform' 'ocaml-lsp-server.1.15.1-5.0-ocaml5.0.0+platform' 'merlin.4.8-500-ocaml5.0.0+platform' 'dune-release.1.6.2+platform' 'dune.3.7.1-ocaml5.0.0+platform' '--yes' '-q' '--color=never' '--root' '/home/<user>/.opam':
[ERROR] The sources of the following couldn't be obtained, aborting:
          - dune.3.7.1-ocaml5.0.0+platform
          - dune-release.1.6.2+platform
          - merlin.4.8-500-ocaml5.0.0+platform
          - ocaml-lsp-server.1.15.1-5.0-ocaml5.0.0+platform
          - ocamlformat.0.25.1+platform
          - odoc.2.2.0-ocaml5.0.0+platform

ocaml-platform: [ERROR] Command 'opam install ocamlformat.0.25.1+platform
           odoc.2.2.0-ocaml5.0.0+platform
           ocaml-lsp-server.1.15.1-5.0-ocaml5.0.0+platform
           merlin.4.8-500-ocaml5.0.0+platform dune-release.1.6.2+platform
           dune.3.7.1-ocaml5.0.0+platform --yes -q --color=never --root
           /home/<user>/.opam' failed: exited with 40

My repositories list (opam repositories) is:

[NOTE] These are the repositories in use by the current switch. Use '--all' to see all
       configured repositories.

<><> Repository configuration for switch default ><><><><><><><><><><><><><><><>
 1 platform-cache file:///home/<user>/.opam/plugins/ocaml-platform/cache/repo
 2 default        https://opam.ocaml.org
panglesd commented 1 year ago

Thanks. Unfortunately, opam does not give any more information about why "The sources couldn't be obtained"...

Could you check the content one of the opam file corresponding to the package to install, e.g. ~/.opam/plugins/ocaml-platform/cache/repo/packages/odoc/odoc.2.2.0-ocaml5.0.0+platform/opam ?

For instance in my case:

$ cat ~/.opam/plugins/ocaml-platform/cache/repo/packages/odoc/odoc.2.2.0-ocaml5.0.0+platform/opam 
opam-version: "2.0"
name: "odoc"
depends: [
  "ocaml-system" {= "5.0.0"} | "ocaml-variants" {= "5.0.0"} |
  "ocaml-base-compiler" {= "5.0.0"}
]
available: arch = "x86_64" & os-distribution = "ubuntu"
url {
  src:
    "/home/<user>/.opam/plugins/ocaml-platform/cache/archives/odoc.2.2.0-ocaml5.0.0+platform.tar.gz"
}

shows the archive is supposed to be in /home/<user>/.opam/plugins/ocaml-platform/cache/archives/odoc.2.2.0-ocaml5.0.0+platform.tar.gz, and I can verify that:

$ ls /home/<user>/.opam/plugins/ocaml-platform/cache/archives/                                     
dune-release.1.6.2+platform.tar.gz  ocaml-lsp-server.1.13.2~5.0preview-ocaml5.0.0+platform.tar.gz
ocamlformat.0.22.4+platform.tar.gz  ocaml-lsp-server.1.14.2-ocaml4.14.0+platform.tar.gz
ocamlformat.0.24.1+platform.tar.gz  odoc.2.1.1-ocaml4.14.0+platform.tar.gz
ocamlformat.0.25.1+platform.tar.gz  odoc.2.2.0-ocaml5.0.0+platform.tar.gz

If your ~/.opam/plugins/ocaml-platform/cache/archives is empty or incomplete, it will be hard to know how it happened.

To make ocaml-platform work again, you can just remove the ~/.opam/plugins/ocaml-platform folder, which will wipe the cache (you will have to recompile the binaries for each tools next time you run the installer). Let me know if this works!

e10e3 commented 1 year ago

Here is the contents of the opam file for one of the packages:

$ cat ~/.opam/plugins/ocaml-platform/cache/repo/packages/odoc/odoc.2.2.0-ocaml5.0.0+platform/opam 
opam-version: "2.0"
name: "odoc"
depends: [
  "ocaml-system" {= "5.0.0"} | "ocaml-variants" {= "5.0.0"} |
  "ocaml-base-compiler" {= "5.0.0"}
]
available: arch = "x86_64" & os-distribution = "debian"
url {
  src:
    "/home/<user>/.opam/plugins/ocaml-platform/cache/archives/odoc.2.2.0-ocaml5.0.0+platform.tar.gz"

The local archive is indeed where indicated:

$ ls ~/.opam/plugins/ocaml-platform/cache/archives/
dune.3.7.1-ocaml5.0.0+platform.tar.gz
dune-release.1.6.2+platform.tar.gz
merlin.4.8-500-ocaml5.0.0+platform.tar.gz
ocamlformat.0.25.1+platform.tar.gz
ocaml-lsp-server.1.15.1-5.0-ocaml5.0.0+platform.tar.gz
odoc.2.2.0-ocaml5.0.0+platform.tar.gz

As you can see, I have similar results to yours.

After wiping the cache by deleting ~/.opam/plugins/ocaml-platform, ocaml-platform indeed recompiled the binaries for the tools, but the installation failed in the same way as before, with the same error output.

panglesd commented 1 year ago

What's happening is really strange!

Could you install one of the platform package directly with opam?

$ opam install ocamlformat.0.25.1+platform -vv

and report the result? (And if -vv is not enough, maybe try -vvv?)

e10e3 commented 1 year ago

Installing one of the packages directly in verbose mode gave me this:

$ opam install ocamlformat.0.25.1+platform -vv
+ /usr/bin/lsb_release "-s" "-r"
- 11
The following actions will be performed:
  ∗ install ocamlformat 0.25.1+platform

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] The sources of the following couldn't be obtained, aborting:
          - ocamlformat.0.25.1+platform:
            "rsync": command not found.

'opam install ocamlformat.0.25.1+platform -vv' failed.

And indeed, rsync could not be found because it was not installed on my system.

Because it is listed in the Debian repos as "only" a recommendation and not a dependency, I was able to install opam without rsync. I reinstalled opam with all the optional dependencies enabled.

I am happy to report the platform installer now works correctly.

Thank you for your help!

e10e3 commented 1 year ago

Looking into this issue on a clean environment, I saw that the installation instructions given on the OCaml site (they are the ones I followed) are different from the ones on GitHub.

The OCaml site gives gcc, bzip2, make, bubblewrap, patch, curl and unzip as dependencies, with a command to install them:

$ sudo apt install build-essential bubblewrap unzip

The GitHub Readme gives a different command:

sudo apt install bzip2 make gcc bubblewrap rsync patch curl unzip

Both rsync and curl are missing in the command given on ocaml.org.

Additionally, the rsync dependency is given in the command on GitHub, but not written in the text above it.

panglesd commented 1 year ago

I'm glad I was able to help!

Indeed, rsync is missing from the in-text list of dependencies. I will add it (the exact list of dependencies we should mention has never been very clear, see https://github.com/tarides/ocaml-platform-installer/pull/84#discussion_r961734398 and #120)

I will also open an issue on ocaml.org.

One issue that remains is that opam's error message was not included in ocaml-platform's message. I'll have to check why, I though it was supposed to be included.