我喜欢dev.realworldocaml.org学习OCaml。我被困在无法访问ocamlfind库的安装位置。
我的默认ocaml是通过自制软件安装的4.07.0:
PrisBook:〜prisc_000 $酿造清单ocaml
/usr/local/Cellar/ocaml/4.07.0_1/bin/ocaml
Opam是opam V2:
PrisBook:〜prisc_000 $ opam --version 2.0.0
当我尝试安装opam install core utop
时,出现以下错误。
> 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"
我不是很确定,因为我是新来的。如何在Mac上安装ocamlfind
?
谢谢。
答案 0 :(得分:0)
似乎该错误发生在运行opam沙箱脚本的情况下
解决方案:
在这种情况下,解决方案是进入usr/local/bin
,那里展示了opam和opam v2的某些早期版本。我手动删除了所有的opam。然后,我运行brew remove camlp4 ocamlbuild ocaml
,以使opam只看到ocaml编译器的沙盒版本。我删除了〜/ .opam目录,然后通过git将其重新安装
wget https://raw.github.com/ocaml/opam/master/shell/install.sh
,因为安装了opam 1.2的自制软件尚不支持opam v2。
然后我运行opam install core utop
,并成功安装ocamlbuild 1.8.0。
注意:此设置没有破坏我的reasonml项目。
答案 1 :(得分:0)
我的OCaml版本:The OCaml toplevel, version 4.07.0
我的opam版本:2.0.1
在安装ocamlfind 1.8.0
时遇到了同样的问题。这是因为我的/usr/local/lib/ocaml/nat.cmi
文件用于OCaml的旧版本。我删除了/usr/local/lib/ocaml
文件夹,并通过自制软件重新安装了OCaml。这样,命令opam install core utop
就可以很好地工作了。