2

On a completely fresh ubuntu 18.04 VM I tried to install opam:

$ wget https://github.com/ocaml/opam/releases/download/2.1.0/opam-2.1.0-x86_64-linux
$ mv opam-2.1.0-x86_64-linux opam
$ chmod 777 opam
$ ./opam init

And here is the error I got

<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><>
[ERROR] Could not update repository "default": OpamDownload.Download_fail(_,
        "Download command failed: \"/usr/bin/wget --content-disposition -t 3 -O
        /tmp/opam-5936-f23d09/index.tar.gz.part -U opam/2.1.0 --
        https://opam.ocaml.org/index.tar.gz\" exited with code 5 \"ERROR:
        cannot verify opam.ocaml.org's certificate, issued by
        \226\128\152CN=Zscaler Intermediate Root CA (zscaler.net) (t)\\\\
        ,OU=Zscaler Inc.,O=Zscaler Inc.,ST=California,C=US\226\128\153:\"")
[ERROR] Initial download of repository failed.

How should I solve this?

OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87

1 Answers1

2

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.

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 the help from my professor)

Tejas Anil Shah
  • 1,421
  • 11
  • 20