2

I have installed opam 2.1.0 on a Linux Virtualbox VM. When I try opam init, I get the following error:

<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><>
[ERROR] Could not update repository "default": OpamDownload.Download_fail(_, "Curl
        failed: \"/snap/bin/curl --write-out %{http_code}\\\\n --retry 3
        --retry-delay 2 --user-agent opam/2.1.0 -L -o
        /tmp/opam-32196-d33843/index.tar.gz.part --
        https://opam.ocaml.org/index.tar.gz\" exited with code 23")
[ERROR] Initial download of repository failed.

Running with --disable-sandboxing doesn't help. I know that its a problem creating/writing to /tmp/opam-... directory because if I replace that with my current directory or home directory the command by itself runs fine. It also runs fine with /tmp/opam-... if I use the --create-dirs option in curl but I don't have any way of getting opam init to use that option. Any ideas?

thanks

Motorhead
  • 928
  • 6
  • 16

1 Answers1

1

Update

The reason opam init failed for me was because curl was installed with snap on my system. This exactly what is going on with your VM. Try to run opam init -verbose and that could reveal more about why you ran into an error. In my case I needed to install other things with opam and it kept failing every time. So snap uninstall curl and then sudo apt install curl fixed things. (Was only able to figure this out with help from my professor)

Workaround

I ran into the same issue and I found a workaround on the OCaml forum: here. (Credits to UnixJunkie)

You can run:

opam init github git+https://github.com/ocaml/opam-repository.git

This should avoid the certificate issues. This worked for me.

I tried to fix the certificate issues using this answer as well. You could try doing that, but it seems complicated when the workaround is to simply point it to the github repo directly.

This question is similar to this one.

Tejas Anil Shah
  • 1,421
  • 11
  • 20
  • for me curl isn't installed and even though that worked future commands don't work. I think. Perhaps curl is just updated not 100% sure. – Charlie Parker May 18 '23 at 02:40