1

I have an issue here, that really drives me nuts. I never worked with OCaml, do not know anything about it or how it works.

The problem: i need to install camlidl library. I did it through opam (opam install camlidl).

As i said before, i have no idea about OCaml. ocamlfind list, did not show a package list . Searched the net - found out that running eval $'opam config eval' helps.

strangely (i do not know why) ocamlfind was able to see the package after this command execution, BUT(!) if i run sudo ocamlfind list it will show the list without this package.

Can anyone help me understand why is this happening and how to fix this? I need to compile something that requires camlidl, and it has to be done under sudo.

Thank You in advance!

Execution of ocamlfind list

bigarray            (version: [distributed with Ocaml])
bytes               (version: [OCaml strictly before 4.02])
camlidl             (version: 1.05)
camlp4              (version: [distributed with Ocaml])
camlp4.exceptiontracer (version: [distributed with Ocaml])
camlp4.extend       (version: [distributed with Ocaml])
camlp4.foldgenerator (version: [distributed with Ocaml])
camlp4.fulllib      (version: [distributed with Ocaml])
camlp4.gramlib      (version: [distributed with Ocaml])
camlp4.lib          (version: [distributed with Ocaml])
camlp4.listcomprehension (version: [distributed with Ocaml])
camlp4.locationstripper (version: [distributed with Ocaml])
camlp4.macro        (version: [distributed with Ocaml])
camlp4.mapgenerator (version: [distributed with Ocaml])
camlp4.metagenerator (version: [distributed with Ocaml])
camlp4.profiler     (version: [distributed with Ocaml])
camlp4.quotations   (version: [distributed with Ocaml])
camlp4.quotations.o (version: [distributed with Ocaml])
camlp4.quotations.r (version: [distributed with Ocaml])
camlp4.tracer       (version: [distributed with Ocaml])
compiler-libs       (version: [distributed with Ocaml])
compiler-libs.bytecomp (version: [distributed with Ocaml])
compiler-libs.common (version: [distributed with Ocaml])
compiler-libs.optcomp (version: [distributed with Ocaml])
compiler-libs.toplevel (version: [distributed with Ocaml])
dynlink             (version: [distributed with Ocaml])
findlib             (version: 1.5.5)
graphics            (version: [distributed with Ocaml])
labltk              (version: [distributed with Ocaml])
num                 (version: [distributed with Ocaml])
num-top             (version: 1.5.5)
num.core            (version: [internal])
oUnit               (version: 2.0.0)
oUnit.advanced      (version: 2.0.0)
oUnit.threads       (version: 2.0.0)
ocamlbuild          (version: [distributed with Ocaml])
ocamlgraph          (version: 1.8.6)
stdlib              (version: [distributed with Ocaml])
str                 (version: [distributed with Ocaml])
threads             (version: [distributed with Ocaml])
threads.posix       (version: [internal])
threads.vm          (version: [internal])
unix                (version: [distributed with Ocaml])

Execution of sudo ocamlfind list

bigarray            (version: [distributed with Ocaml])
camlp4              (version: [distributed with Ocaml])
camlp4.exceptiontracer (version: [distributed with Ocaml])
camlp4.extend       (version: [distributed with Ocaml])
camlp4.foldgenerator (version: [distributed with Ocaml])
camlp4.fulllib      (version: [distributed with Ocaml])
camlp4.gramlib      (version: [distributed with Ocaml])
camlp4.lib          (version: [distributed with Ocaml])
camlp4.listcomprehension (version: [distributed with Ocaml])
camlp4.locationstripper (version: [distributed with Ocaml])
camlp4.macro        (version: [distributed with Ocaml])
camlp4.mapgenerator (version: [distributed with Ocaml])
camlp4.metagenerator (version: [distributed with Ocaml])
camlp4.profiler     (version: [distributed with Ocaml])
camlp4.quotations   (version: [distributed with Ocaml])
camlp4.quotations.o (version: [distributed with Ocaml])
camlp4.quotations.r (version: [distributed with Ocaml])
camlp4.tracer       (version: [distributed with Ocaml])
compiler-libs       (version: [distributed with Ocaml])
compiler-libs.bytecomp (version: [distributed with Ocaml])
compiler-libs.common (version: [distributed with Ocaml])
compiler-libs.optcomp (version: [distributed with Ocaml])
compiler-libs.toplevel (version: [distributed with Ocaml])
dynlink             (version: [distributed with Ocaml])
findlib             (version: 1.4.1)
graphics            (version: [distributed with Ocaml])
labltk              (version: [distributed with Ocaml])
num                 (version: [distributed with Ocaml])
num-top             (version: 1.4.1)
num.core            (version: [internal])
oUnit               (version: 2.0.0)
oUnit.advanced      (version: 2.0.0)
oUnit.threads       (version: 2.0.0)
ocamlbuild          (version: [distributed with Ocaml])
ocamlgraph          (version: 1.8.5)
stdlib              (version: [distributed with Ocaml])
str                 (version: [distributed with Ocaml])
threads             (version: [distributed with Ocaml])
threads.posix       (version: [internal])
threads.vm          (version: [internal])
unix                (version: [distributed with Ocaml])

Execution of opam

Installed packages for system:
base-bigarray   base  Bigarray library distributed with the OCaml compiler
base-threads    base  Threads library distributed with the OCaml compiler
base-unix       base  Unix library distributed with the OCaml compiler
camlidl         1.05  Stub code generator for OCaml
ocamlfind      1.5.5  A library manager for OCaml
ocamlgraph     1.8.6  A generic graph library for OCaml
ounit          2.0.0  Unit testing framework loosely based on HUnit. It is similar to JUnit, and other XUnit testing frameworks

Execution for sudo -i opam list

Installed packages for system:
base-bigarray   base  Bigarray library distributed with the OCaml compiler
base-threads    base  Threads library distributed with the OCaml compiler
base-unix       base  Unix library distributed with the OCaml compiler
camlidl         1.05  Stub code generator for OCaml
4

1 回答 1

1

eval $(opam config env)使用变量填充您的环境,这有助于ocamlfind在 Python 中查找库,参见 PIP 的虚拟环境。

当您在用户帐户下评估此命令时,您仅为一个用户填充环境,因此它对包括 root 在内的其他用户不可见。此外,通常,您在用户本地模式下安装 ocaml 包,而不是在系统范围内。

为了解决您的问题,无需深入研究 OCaml 基础架构,我会建议以下内容,

  1. 如果可能,请不要使用sudo. 实际上,我看不到sudo用于编译的原因。它可能仅在安装时需要。所以,使用makesudo make install。如果您已经不小心make使用sudo它运行,可能会在 root 所有权下创建文件,因此您需要删除所有内容并从头开始。

  2. 如果不可能(包构建系统如此糟糕),则尝试在 root 用户下安装 opam,并以 root 身份执行所有操作,例如,切换到 root 模式sudo su -并正常继续。

于 2015-04-21T17:55:05.023 回答