-->

not able to install anything using opam

2019-05-30 18:47发布

问题:

I installed opam with homebrew on Mac OS X 10.10. But I can't install anything using opam. This is an example error output that get when I try to install ocamlfind:

# opam-version 1.2.0
# os           darwin
# command      ./configure -bindir /Users/roger/.opam/system/bin -sitelib /Users/roger/.opam/system/lib -mandir /Users/roger/.opam/system/man -config /Users/roger/.opam/system/lib/findlib.conf -no-topfind
# path         /Users/roger/.opam/system/build/ocamlfind.1.5.5
# compiler     system (4.02.1)
# exit-code    1
# env-file     /Users/roger/.opam/system/build/ocamlfind.1.5.5/ocamlfind-91360-c61e7b.env
# stdout-file  /Users/roger/.opam/system/build/ocamlfind.1.5.5/ocamlfind-91360-c61e7b.out
# stderr-file  /Users/roger/.opam/system/build/ocamlfind.1.5.5/ocamlfind-91360-c61e7b.err
### stdout ###
# ...[truncated]
# Configuration for str written to site-lib-src/str/META
# Configuration for threads written to site-lib-src/threads/META
# Configuration for unix written to site-lib-src/unix/META
# Configuration for stdlib written to site-lib-src/stdlib/META
# Configuration for bigarray written to site-lib-src/bigarray/META
# Configuration for camlp4 written to site-lib-src/camlp4/META
# Configuration for ocamlbuild written to site-lib-src/ocamlbuild/META
# Configuration for compiler-libs written to site-lib-src/compiler-libs/META
# Configuration for bytes written to site-lib-src/bytes/META
# Detecting compiler arguments: FAILED (see the file ocargs.log for details)
### stderr ###
# ./configure: line 547: cd: src: No such file or directory

回答1:

brew install opam
opam init --comp=4.02.1
eval `opam config env`
ocaml

Update:

Sometimes brewed opam can fail with Illegal Instruction, in that case you need to reinstall opam from sources:

brew reinstall --build-from-source opam

Also, you need a working toolchain, i.e., compiler, autotools and other developer tools. You can try to install it using brew, e.g., brew install autotools, etc. Or you can try to install xcode toolchain, including apple command line developer tools.



回答2:

I had the same problem trying to install mirage, the problem is because the current directory is not in the CDPATH by default on macOS X. The posix /bin/sh will not "cd src" though can "cd ./src". The quick fix is to do the following before running opam (or just put it in your .bash_profile.

export CDPATH=. opam install WHATEVER



标签: ocaml opam