首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >命令"sudo ocamlfind list“和"ocamlfind list”的不同结果

命令"sudo ocamlfind list“和"ocamlfind list”的不同结果
EN

Stack Overflow用户
提问于 2015-04-21 17:46:35
回答 1查看 245关注 0票数 1

我这里有个问题,真让我抓狂。我从未与OCaml合作过,也不知道它是如何工作的。

问题是:我需要安装camlidl库。我是通过opam (opam install camlidl)做的。

正如我之前所说的,我对OCaml一无所知。ocamlfind list没有显示包列表。在网上搜索,发现运行eval $'opam config eval'会有所帮助。

奇怪的是(我不知道为什么)在这个命令执行之后ocamlfind能够看到包,但是(!)如果我运行sudo ocamlfind list,它将显示没有此包的列表。

有人能帮我理解为什么会发生这种事,以及如何解决这个问题吗?我需要编译一些需要camlidl的东西,它必须在sudo下完成。

提前谢谢你!

ocamlfind list的执行

代码语言:javascript
复制
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])

sudo ocamlfind list的执行

代码语言:javascript
复制
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])

opam的执行

代码语言:javascript
复制
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

sudo -i opam list的执行

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-21 17:55:05

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

在用户帐户下计算此命令时,只为用户填充环境,因此其他用户(包括root用户)看不到该环境。此外,通常情况下,您在用户本地模式下安装ocaml包,而不是在系统范围内安装。

为了解决您的问题,在不深入研究OCaml基础结构的情况下,我建议如下:

  1. 如果可能的话,不要使用sudo。实际上,我不认为使用sudo进行编译的原因。可能只需要安装。所以,使用makesudo make install。如果您已经不小心使用make运行sudo,它可能会创建根所有权下的文件,因此您需要删除所有内容并从头开始。
  2. 如果不可能(包构建系统被破坏),那么尝试在根用户下安装opam,并以根用户的身份执行所有操作,例如,使用sudo su -切换到根模式,然后继续正常运行。
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29779568

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档