Lucia Garcia
Lucia Garcia

Reputation: 61

opam init failure upon attempted OCaml installation on MacOS 10.14.16

I am attempting to install OCaml via the OCaml opam package manager on MacOs. I have successfully installed opam via homebrew. Initiating the package manager with opam init yields the following error:

[ERROR] Could not update repository "default":
        OpamDownload.Download_fail(_, "Curl failed: \"/usr/bin/curl
        --write-out %{http_code}\\\\n --retry 3 --retry-delay 2
        --user-agent opam/2.1.0 -L -o
        /private/var/folders/c_/6splkz692w16x82lzgnsxgfr0000gn/T/opam-57814-6b2069/index.tar.gz.part
        -- https://opam.ocaml.org/index.tar.gz\" exited with code 60")
[ERROR] Initial download of repository failed.

What can I do to facilitate successful connection to the repository and initialise opam?

Upvotes: 6

Views: 3847

Answers (4)

Delcio Kelson
Delcio Kelson

Reputation: 86

Install curl first.

On MacOS: brew install curl

On Debian/Ubuntu Linux (and derivations): sudo apt-get install curl

Upvotes: 1

Tejas Anil Shah
Tejas Anil Shah

Reputation: 1563

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.

I tried to use ivg's solution but must have made a mistake in moving the .pem files, so I couldn't get that solution to work. The workaround was quick.

Update

The reason opam init failed for me was because curl was installed with snap on my system. 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)

Upvotes: 3

Gerardo Zinno
Gerardo Zinno

Reputation: 1712

I had the same problem and solved it by first running brew install wget and then opam init, which suddenly worked.

Upvotes: 6

ivg
ivg

Reputation: 35210

This error message indicates that curl is unable to establish the authenticity of the peer, i.e., https://opam.ocaml.org

This could happen because the certificates on either side are outdated. We can easily check if opam.ocaml.org is up-to-date, using one of the available online SSL checkers, e.g., this one says that they are OK. So it looks like that the problem is on your side.

First of all, you should try using your operating system upgrading options to get everything up-to-date.

If it is not an option, then you can use the --insecure option that you can pass using the OPAMFETCH environment variables. Or you can download the corresponding certificates and store a path to them in the ~/.curlrc, look here for more information.

Upvotes: 6

Related Questions