I followed the installation guide at Install OCaml – OCaml, using brew on Mac M1. At the step where I’m supposed to run opam init, I got:
$ opam init -v
No configuration file found, using built-in defaults.
Checking for available remotes: rsync and local, git.
- you won't be able to use mercurial repositories unless you install the hg command on your system.
- you won't be able to use darcs repositories unless you install the darcs command on your system.
<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><> 🐫
[default] Initialised
[ERROR] Could not update repository "default": /opt/homebrew/bin/opam: "create_process" failed on /opt/homebrew/opt/openssl: Permission denied
[ERROR] Initial download of repository failed.
'opam init -v' failed.
When I Googled for the error message (“opam init” create_process openssl), all issues I’ve found seem to be about Cygwin on Windows not being able to find sh, which is not the case for my situation. So I’m kinda stuck. What should I do?
Here’s the result of opam init -v -v, in case it’s useful:
$ opam init -v -v
No configuration file found, using built-in defaults.
Checking for available remotes: rsync and local, git.
- you won't be able to use mercurial repositories unless you install the hg command on your system.
- you won't be able to use darcs repositories unless you install the darcs command on your system.
+ /Users/sorawee/.opam/opam-init/hooks/sandbox.sh "build" "sh" "-c" "echo SUCCESS >$TMPDIR/opam-sandbox-check-out && cat $TMPDIR/opam-sandbox-check-out; rm -f $TMPDIR/opam-sandbox-check-out"
- SUCCESS
<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><> 🐫
+ /opt/homebrew/bin/wget "--content-disposition" "-t" "3" "-O" "/private/var/folders/8v/ssfgpb5d67n4jrvmszsh7y800000gn/T/opam-15331-7b8acb/index.tar.gz.part" "-U" "opam/2.1.2" "--" "https://opam.ocaml.org/index.tar.gz"
- --2022-04-02 20:37:12-- https://opam.ocaml.org/index.tar.gz
- Resolving opam.ocaml.org (opam.ocaml.org)... 54.146.41.74
- Connecting to opam.ocaml.org (opam.ocaml.org)|54.146.41.74|:443... connected.
- HTTP request sent, awaiting response... 200 OK
- Length: 5217105 (5.0M) [application/gzip]
- Saving to: ‘/private/var/folders/8v/ssfgpb5d67n4jrvmszsh7y800000gn/T/opam-15331-7b8acb/index.tar.gz.part’
-
- 0K .......... .......... .......... .......... .......... 0% 153K 33s
<elided>
- 5050K .......... .......... .......... .......... .... 100% 79.7M=1.9s
-
- 2022-04-02 20:37:14 (2.61 MB/s) - ‘/private/var/folders/8v/ssfgpb5d67n4jrvmszsh7y800000gn/T/opam-15331-7b8acb/index.tar.gz.part’ saved [5217105/5217105]
-
+ /usr/bin/tar "xfz" "/private/var/folders/8v/ssfgpb5d67n4jrvmszsh7y800000gn/T/opam-15331-7b8acb/index.tar.gz" "-C" "/Users/sorawee/.opam/repo/default.new"
[default] Initialised
+ /usr/bin/tar "cfz" "/Users/sorawee/.opam/repo/default.tar.gz.tmp" "-C" "/Users/sorawee/.opam/repo" "default"
[ERROR] Could not update repository "default": /opt/homebrew/bin/opam: "create_process" failed on /opt/homebrew/opt/openssl: Permission denied
[ERROR] Initial download of repository failed.
'opam init -v -v' failed.
Doesn’t look like an opam problem, but rather a problem with your openssl executable. Are you able to execute /opt/homebrew/opt/openssl? If you get the same error (Permission denied), you can try reinstalling it with Homebrew to see if that solves your problem.
What happened here is that opam try to find openssl in PATH, find the directory /opt/homebrew/opt/openssl, but it’s not the binary.
It’s more an system install / path specification issue: PATH paths are supposed to contain executables at toplevel, and you have a (or more?) directory in /opt/homebrew/opt/.