【问题标题】:Why can't opam install the graphics package?opam为什么不能安装图形包?
【发布时间】:2018-02-10 01:35:48
【问题描述】:

我尝试安装 ocaml 图形包,但它失败了。关于如何修复它的任何建议?

~/Documents/Work/Code/OCaml with graphics: opam update

=-=- Updating package repositories =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  ???? 
[default: http] Command started
[default: http] Command started
[default] synchronized from https://opam.ocaml.org

~/Documents/Work/Code/OCaml with graphics: opam upgrade
Already up-to-date.

~/Documents/Work/Code/OCaml with graphics: opam install graphics
The following actions will be performed:
  ∗  install graphics 1.0

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  ???? 

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  ???? 
[graphics: ocamlc graphics.cma] Command started
[ERROR] The compilation of graphics failed at "ocamlc -custom graphics.cma -o
        test".

#=== ERROR while installing graphics.1.0 ======================================#
# opam-version         1.2.2
# os                   darwin
# command              ocamlc -custom graphics.cma -o test
# path                 /Users/Tim/.opam/system/build/graphics.1.0
# compiler             system (4.04.0)
# exit-code            2
# env-file             /Users/Tim/.opam/system/build/graphics.1.0/graphics-14648-7afd23.env
# stdout-file          /Users/Tim/.opam/system/build/graphics.1.0/graphics-14648-7afd23.out
# stderr-file          /Users/Tim/.opam/system/build/graphics.1.0/graphics-14648-7afd23.err
### stderr ###
# File "_none_", line 1:
# Error: Cannot find file graphics.cma

=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  ???? 
The following actions failed
  ∗  install graphics 1.0
No changes have been performed

=-=- graphics.1.0 troubleshooting -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  ???? 
=> This package checks whether the Graphics library was compiled.

除了缺少图形包外,我的 ocaml 安装工作正常。

这里是 ~/.opam/system/build/graphics.1.0 中文件的内容

首先,graphics-14648-7afd23.err:

File "_none_", line 1:
Error: Cannot find file graphics.cma

然后是 graphics-14648-7afd23.info:

# opam-version         1.2.2
# os                   darwin
# command              ocamlc -custom graphics.cma -o test
# path                 /Users/Tim/.opam/system/build/graphics.1.0
# compiler             system (4.04.0)
# env-file             /Users/Tim/.opam/system/build/graphics.1.0/graphics-14648-7afd23.env
# stdout-file          /Users/Tim/.opam/system/build/graphics.1.0/graphics-14648-7afd23.out
# stderr-file          /Users/Tim/.opam/system/build/graphics.1.0/graphics-14648-7afd23.err

还有 graphics-14648-7afd23.env:

PATH=/Users/Tim/.opam/system/bin:/Library/Frameworks/Python.framework/Versions/3.2/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin:/usr/local/bin
OCAML_TOPLEVEL_PATH=/Users/Tim/.opam/system/lib/toplevel
PERL5LIB=/Users/Tim/.opam/system/lib/perl5:
MANPATH=/Users/Tim/.opam/system/man:/opt/local/share/man:
OPAMSWITCH=system
OPAMUTF8MSGS=1
CAML_LD_LIBRARY_PATH=/Users/Tim/.opam/system/lib/stublibs:/usr/local/lib/ocaml/stublibs
SHELL=/bin/bash
TERM=dumb
TMPDIR=/var/folders/kv/kmn525v16kb2mz2hrhq3q4mh0000gn/T/
BASHRC_HAS_BEEN_RUN=1
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.8tP8Ej926f/Render
EMACSDATA=/Applications/Emacs.app/Contents/Resources/etc
OLDPWD=/Users/Tim/Documents/Work/Code
EMACSPATH=/Applications/Emacs.app/Contents/MacOS/bin
USER=Tim
EMACS=t
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.EXKwsf0Dz0/Listeners
TERMCAP=
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
COLUMNS=190
BASH_PROFILE_HAS_BEEN_RUN=1
PWD=/Users/Tim/Documents/Work/Code/OCaml with graphics
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
EMACSLOADPATH=/Applications/Emacs.app/Contents/Resources/site-lisp:/Applications/Emacs.app/Contents/Resources/lisp:/Applications/Emacs.app/Contents/Resources/leim
SHLVL=1
HOME=/Users/Tim
LOGNAME=Tim
INFOPATH=/Applications/Emacs.app/Contents/Resources/info:
DISPLAY=/private/tmp/com.apple.launchd.jPYPDR7RIj/org.macosforge.xquartz:0
INSIDE_EMACS=23.1.1,comint
EMACSDOC=/Applications/Emacs.app/Contents/Resources/etc
_=/usr/local/bin/opam
OPAM_PACKAGE_VERSION=1.0
OPAM_PACKAGE_NAME=graphics
MAKELEVEL=
MAKEFLAGS=

最终文件 graphics-14648-7afd23.env 为空。

【问题讨论】:

  • 您能给我们提供/Users/Tim/.opam/system/build/graphics.1.0/graphics-14648-7afd23.*文件的内容吗?
  • 好的,我已经添加了。
  • 你运行eval `opam config env` 了吗?如果您不了解此命令,请运行 opam init 并按照它输出的说明进行操作。
  • 我认为@nekketsuuu 是正确的eval $(opam config env) 应该这样做。
  • 我运行了eval $(opam config env)(我已经设置了.bash_profile 和.ocamlinit),并再次尝试了opam install graphics,但得到的结果与之前相同。还有其他建议吗?

标签: ocaml opam


【解决方案1】:

编辑:这个答案没有解决 OP 的问题。但我觉得这个答案还是有价值的,所以我把这个留在这里。


通过 OPAM 安装 OCaml 编译器,使用 opam switch <version number here>(可用版本号由 opam switch 显示)。 The graphics package 是一个用于检查the Graphics library 可用性的虚拟包,因此如果系统的OCaml 上没有库,opam install graphics 将失败。

您可以通过运行ls ~/.opam/*/lib/ocaml/graphics.cma 来确认图形库的存在。如果未找到文件,则未安装 Graphics,因此安装失败是有效行为。我不知道未安装 Graphics 的确切原因,但也许 Graphics 需要安装 X11 很重要。尤其是在 macOS 上安装 XQuartz 是很有必要的。有关详细信息,请参阅Shoe's answer。此外,之后还需要通过 OPAM 重新安装 OCaml。我们可以通过运行重新安装 OCaml:

opam switch reinstall <version number here>

【讨论】:

  • 感谢您的建议,但似乎没有帮助。我收到同样的错误消息。
  • 综上所述,opam install graphics 只检查图形库是否内置。它应该由opam install ocaml 内置。但是macOS不包括X11,图形需要X11,所以我必须用brew install Caskroom/cask/xquartz安装XQuartz(X11的macOS版本)(然后重启我的电脑),然后用brew reinstall ocaml --with-x11重新安装ocaml。然后图形库应该包含在 ocaml 中,opam install graphics 应该验证它是否可用。我试过了,不高兴:我仍然得到# Error: Cannot find file graphics.cma
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-05-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多