I'm follwing dev.realworldocaml.org to learn OCaml. I'm stuck at installing where I can't get access to the ocamlfind library.
My default ocaml is 4.07.0 installed via homebrew:
PrisBook:~ prisc_000$ brew list ocaml
/usr/local/Cellar/ocaml/4.07.0_1/bin/ocaml
Opam is opam V2:
PrisBook:~ prisc_000$ opam --version 2.0.0
When I try to install opam install core utop
, I get the following error.
> PrisBook:~ prisc_000$ opam switch
# switch compiler description
→ default ocaml-system.4.07.0 default
PrisBook:~ prisc_000$ opam install core utop
The following actions will be performed:
∗ install jane-street-headers v0.11.0
[required by core_kernel]
∗ install ocamlfind 1.8.0
[required by utop]
∗ install seq base
[required by re]
∗ install camomile 1.0.1
[required by utop]
∗ install spawn v0.12.0
[required by core]
∗ install ocaml-compiler-libs v0.11.0
[required by ppxlib]
∗ install sexplib0 v0.11.0
[required by base]
∗ install ppx_derivers 1.0
[required by ppxlib]
∗ install topkg 0.9.1
[required by react]
∗ install octavius 1.2.0
[required by ppx_js_style]
∗ install ocaml-migrate-parsetree 1.0.11
[required by core]
∗ install num 1.1
[required by sexplib]
∗ install base-bytes base
[required by cppo]
∗ install re 1.8.0
[required by ppx_expect]
∗ install parsexp v0.11.0
[required by sexplib]
∗ install base v0.11.1
[required by core]
∗ install react 1.2.1
[required by utop]
∗ install cppo 1.6.4
[required by utop]
∗ install sexplib v0.11.0
[required by core]
∗ install typerep v0.11.0
[required by core_kernel]
∗ install stdio v0.11.0
[required by core]
∗ install zed 1.6
[required by lambda-term]
∗ install lwt 4.1.0
[required by utop]
For the PPX, please install package lwt_ppx
∗ install ppxlib 0.3.0
[required by core]
∗ install configurator v0.11.0
[required by core]
∗ install lwt_react 1.1.1
[required by utop]
∗ install lwt_log 1.1.0
[required by lambda-term]
∗ install variantslib v0.11.0
[required by core_kernel]
∗ install ppx_typerep_conv v0.11.1
[required by ppx_jane]
∗ install ppx_sexp_conv v0.11.2
[required by core_kernel]
∗ install ppx_pipebang v0.11.0
[required by ppx_jane]
∗ install ppx_optional v0.11.0
[required by ppx_jane]
∗ install ppx_optcomp v0.11.0
[required by ppx_jane]
∗ install ppx_let v0.11.0
[required by ppx_jane]
∗ install ppx_js_style v0.11.0
[required by ppx_base]
∗ install ppx_inline_test v0.11.0
[required by core_kernel]
∗ install ppx_here v0.11.0
[required by ppx_assert, ppx_jane]
∗ install ppx_enumerate v0.11.1
[required by ppx_base]
∗ install ppx_compare v0.11.1
[required by ppx_assert, bin_prot, ppx_base]
∗ install fieldslib v0.11.0
[required by core_kernel]
∗ install lambda-term 1.13
[required by utop]
∗ install ppx_variants_conv v0.11.1
[required by bin_prot, ppx_jane]
∗ install ppx_custom_printf v0.11.0
[required by bin_prot, ppx_jane]
∗ install ppx_bench v0.11.0
[required by ppx_jane]
∗ install ppx_sexp_value v0.11.0
[required by ppx_jane]
∗ install ppx_sexp_message v0.11.0
[required by core_kernel]
∗ install ppx_fail v0.11.0
[required by ppx_jane]
∗ install ppx_hash v0.11.1
[required by core_kernel]
∗ install ppx_assert v0.11.0
[required by core]
∗ install ppx_fields_conv v0.11.0
[required by bin_prot, ppx_jane]
∗ install utop 2.2.0
∗ install ppx_base v0.11.0
[required by core_kernel]
∗ install ppx_expect v0.11.0
[required by ppx_jane]
∗ install bin_prot v0.11.0
[required by core_kernel]
∗ install ppx_bin_prot v0.11.1
[required by ppx_jane]
∗ install ppx_jane v0.11.0
[required by core]
∗ install splittable_random v0.11.0
[required by core_kernel]
∗ install core_kernel v0.11.1
[required by core]
∗ install core v0.11.2
===== ∗ 59 =====
Do you want to continue? [Y/n] y
<><> Gathering sources ><><><><><><><><><><><><><><><><> 🐫
[base.v0.11.1] downloaded from cache at https://opam.ocaml.org/2.0/cache
[bin_prot.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[configurator.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[core_kernel.v0.11.1] downloaded from cache at https://opam.ocaml.org/2.0/cache
[core.v0.11.2] downloaded from cache at https://opam.ocaml.org/2.0/cache
[camomile.1.0.1] downloaded from cache at https://opam.ocaml.org/2.0/cache
[cppo.1.6.4] downloaded from cache at https://opam.ocaml.org/2.0/cache
[fieldslib.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[jane-street-headers.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[lambda-term.1.13] downloaded from cache at https://opam.ocaml.org/2.0/cache
[lwt_log.1.1.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[lwt.4.1.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ocaml-compiler-libs.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[num.1.1] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ocamlfind.1.8.0] found in cache
[lwt_react.1.1.1] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ocaml-migrate-parsetree.1.0.11] downloaded from cache at https://opam.ocaml.org/2.0/cache
[octavius.1.2.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[parsexp.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_assert.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_base.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_bench.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_compare.v0.11.1] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_bin_prot.v0.11.1] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_custom_printf.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_derivers.1.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_enumerate.v0.11.1] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_fail.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_expect.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_fields_conv.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_hash.v0.11.1] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_here.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_inline_test.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_jane.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_js_style.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_let.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_optcomp.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_optional.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_pipebang.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_sexp_message.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_sexp_conv.v0.11.2] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_sexp_value.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_typerep_conv.v0.11.1] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppx_variants_conv.v0.11.1] downloaded from cache at https://opam.ocaml.org/2.0/cache
[ppxlib.0.3.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[react.1.2.1] downloaded from cache at https://opam.ocaml.org/2.0/cache
[re.1.8.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[sexplib0.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[spawn.v0.12.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[sexplib.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[topkg.0.9.1] found in cache
[splittable_random.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[stdio.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[typerep.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[variantslib.v0.11.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[utop.2.2.0] downloaded from cache at https://opam.ocaml.org/2.0/cache
[zed.1.6] downloaded from cache at https://opam.ocaml.org/2.0/cache
<><> Processing actions <><><><><><><><><><><><><><><><> 🐫
∗ installed jane-street-headers.v0.11.0
∗ installed ocaml-compiler-libs.v0.11.0
∗ installed ppx_derivers.1.0
∗ installed seq.base
[ERROR] The compilation of ocamlfind failed at
"/Users/prisc_000/.opam/opam-init/hooks/sandbox.sh
build make all".
∗ installed sexplib0.v0.11.0
∗ installed parsexp.v0.11.0
∗ installed re.1.8.0
∗ installed spawn.v0.12.0
∗ installed camomile.1.0.1
∗ installed base.v0.11.1
∗ installed stdio.v0.11.0
∗ installed typerep.v0.11.0
∗ installed configurator.v0.11.0
#=== ERROR while compiling ocamlfind.1.8.0 ================#
# context 2.0.0 | macos/x86_64 | ocaml-system.4.07.0 | https://opam.ocaml.org/2.0#0a261aa5
# path ~/.opam/default/.opam-switch/build/ocamlfind.1.8.0
# command ~/.opam/opam-init/hooks/sandbox.sh build make all
# exit-code 2
# env-file ~/.opam/log/ocamlfind-1333-da938f.env
# output-file ~/.opam/log/ocamlfind-1333-da938f.out
### output ###
# [...]
# USE_CYGPATH="0"; \
# export USE_CYGPATH; \
# cat topfind_rd1.p | \
# ../../tools/patch '@SITELIB@' '/Users/prisc_000/.opam/default/lib' \
# >topfind
# ocamlc -I +compiler-libs -opaque -c num_top_printers.mli
# File "num_top_printers.mli", line 1:
# Error: /usr/local/lib/ocaml/nat.cmi
# is not a compiled interface for this version of OCaml.
# It seems to be for an older version of OCaml.
# make[1]: *** [num_top_printers.cmi] Error 2
# make: *** [all] Error 2
<><> Error report <><><><><><><><><><><><><><><><><><><> 🐫
┌─ The following actions failed
│ λ build ocamlfind 1.8.0
└─
┌─ The following changes have been performed (the rest was aborted)
│ ∗ install base v0.11.1
│ ∗ install camomile 1.0.1
│ ∗ install configurator v0.11.0
│ ∗ install jane-street-headers v0.11.0
│ ∗ install ocaml-compiler-libs v0.11.0
│ ∗ install parsexp v0.11.0
│ ∗ install ppx_derivers 1.0
│ ∗ install re 1.8.0
│ ∗ install seq base
│ ∗ install sexplib0 v0.11.0
│ ∗ install spawn v0.12.0
│ ∗ install stdio v0.11.0
│ ∗ install typerep v0.11.0
└─
The former state can be restored with:
opam switch import
"/Users/prisc_000/.opam/default/.opam-switch/backup/state-20180908080830.export"
I'm not really sure what's going here as I'm new to this. How does one install ocamlfind
on a mac?
Thank you.
It would seem that the error happens around the opam sandbox script running
Solution:
The solution, in this case, was to go into usr/local/bin
where I had some previous versions of opam and opam v2 showing. I manually deleted all opam's. I then ran brew remove camlp4 ocamlbuild ocaml
so that opam would only see the sandboxed version of the ocaml compiler. I deleted the ~/.opam directory then reinstalled it from git via
wget https://raw.github.com/ocaml/opam/master/shell/install.sh
because opam v2 is not yet available on homebrew which installs opam 1.2.
I then ran opam install core utop
and ocamlbuild 1.8.0 is successfully installed.
Note: this setup did not break my reasonml projects.