I tried to install the ocaml graphics package, but it fails. Any suggestions for how I can fix it?
~/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.
Other than the missing graphics package, my ocaml install is working fine.
Here are the contents of the files in ~/.opam/system/build/graphics.1.0
First, graphics-14648-7afd23.err:
File "_none_", line 1:
Error: Cannot find file graphics.cma
Then 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
And 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=
The final file, graphics-14648-7afd23.env, is empty.
Edit: this answer didn't solve OP's problem. But I think this answer is still valuable, so I leave this here.
Install the OCaml compiler via OPAM, using opam switch <version number here> (Available version numbers are shown by opam switch). The graphics package is a virtual package to check the availability of the Graphics library, so opam install graphics will fail if there is no library on system's OCaml.
You can confirm the existence of the Graphics library by running ls ~/.opam/*/lib/ocaml/graphics.cma. If no file is found, then Graphics is not installed and therefore the failure of installation is the valid behavior. I don't know the exact reason why Graphics isn't installed, but maybe it's important that Graphics needs X11 to be installed. Especially, it's necessary to install XQuartz on macOS. See Shoe's answer for details. Also, re-installation of OCaml via OPAM will be needed after that. We can reinstall OCaml by running:
opam switch reinstall <version number here>
Related
I've installed this compiler before in a docker container, but I don't understand why it's missing right now. Command and error:
(iit_synthesis) brando9~ $ opam switch create ocaml-variants.4.07.1+flambda_coq-serapi.8.11.0+0.11.1 ocaml-variants.4.07.1+flambda
[ERROR] No compiler matching `ocaml-variants.4.07.1+flambda' found, use `opam switch list-available' to see what is available, or use `--packages' to
select packages explicitly.
but it's not in the list:
(iit_synthesis) brando9~ $ opam switch list-available
# Listing available compilers from repositories: default
# Name # Version # Synopsis
ocaml-option-32bit 1 Set OCaml to be compiled in 32-bit mode for 64-bit Linux and OS X hosts
ocaml-option-flambda 1 Set OCaml to be compiled with flambda activated
ocaml-option-nnpchecker 1 Set OCaml to be compiled with --enable-naked-pointers-checker
ocaml-option-spacetime 1 Set OCaml to be compiled with spacetime activated
ocaml-options-vanilla 1 Ensure that OCaml is compiled with no special options enabled
Opam update fails
Output:
$ opam update --all
<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
Processing 1/1: [default: http]
Processing 1/1: [default: http]
[default] synchronised from https://opam.ocaml.org
[ERROR] Could not update repository "default": "~/anaconda/bin/patch -p1 -i /dfs/scratch0/brando9/.opam/log/patch-99014-0624b6" exited with code 2
I probably should have started with this but I installed opam with "manually" with deb because I don't have sudo. In particular I did this:
# - opam (snap, no sudo)
# ref: https://askubuntu.com/questions/339/how-can-i-install-a-package-without-root-access
apt-get download opam
#apt-get download opam_1.2.2-4_amd64
# manually checked the opam name
#ls | less
mkdir -p ~/.local
dpkg -x opam_1.2.2-4_amd64.deb ~/.local/bin
export PATH="$HOME/.local/bin:$PATH"
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc.user
source ~/.bashrc.user
tr ':' '\n' <<< "$PATH"
opam --version
before that I did try installing opam with conda (which has worked in the past) but it failed. I wonder if that screwed things up :/. Will try to reproduce to post the conda error. But I ran conda install -c conda-forge opam.
related:
How to install a specific version of ocaml compiler with opam
https://discuss.ocaml.org/t/why-doesnt-my-server-show-the-ocaml-compiler-that-i-need/10917
https://www.reddit.com/r/ocaml/comments/zed88p/how_does_one_install_a_specific_ocaml_compiler/
How does one install opam without sudo priveledges on linux/ubuntu?
I reviewed this thread OCaml - Cannot find graphics.cma but unfortunately wasn't able to resolve it finding the recommendation here. I'm on Catalina macos and when running ocamlbuild foo.byte, I get this error:
+ ocamlc.opt str.cma graphics.cma -thread threads.cma foo.cmo -o foo.byte
File "_none_", line 1:
Error: Cannot find file graphics.cma
Command exited with code 2.
Compilation unsuccessful after building 3 targets (0 cached) in 00:00:00.
I tried installing graphics via opam and installing xquartz as well manually after removing the brew version of xquartz which, enabled me to install graphics just fine but still gives me the error above.
Without more details, it sounds like you have not added the "graphics" package to your _tag file. (Detailing this dependency is also required with dune).
I installed opam with homebrew on Mac OS X 10.10. But I can't install anything using opam. This is an example error output that get when I try to install ocamlfind:
# opam-version 1.2.0
# os darwin
# command ./configure -bindir /Users/roger/.opam/system/bin -sitelib /Users/roger/.opam/system/lib -mandir /Users/roger/.opam/system/man -config /Users/roger/.opam/system/lib/findlib.conf -no-topfind
# path /Users/roger/.opam/system/build/ocamlfind.1.5.5
# compiler system (4.02.1)
# exit-code 1
# env-file /Users/roger/.opam/system/build/ocamlfind.1.5.5/ocamlfind-91360-c61e7b.env
# stdout-file /Users/roger/.opam/system/build/ocamlfind.1.5.5/ocamlfind-91360-c61e7b.out
# stderr-file /Users/roger/.opam/system/build/ocamlfind.1.5.5/ocamlfind-91360-c61e7b.err
### stdout ###
# ...[truncated]
# Configuration for str written to site-lib-src/str/META
# Configuration for threads written to site-lib-src/threads/META
# Configuration for unix written to site-lib-src/unix/META
# Configuration for stdlib written to site-lib-src/stdlib/META
# Configuration for bigarray written to site-lib-src/bigarray/META
# Configuration for camlp4 written to site-lib-src/camlp4/META
# Configuration for ocamlbuild written to site-lib-src/ocamlbuild/META
# Configuration for compiler-libs written to site-lib-src/compiler-libs/META
# Configuration for bytes written to site-lib-src/bytes/META
# Detecting compiler arguments: FAILED (see the file ocargs.log for details)
### stderr ###
# ./configure: line 547: cd: src: No such file or directory
brew install opam
opam init --comp=4.02.1
eval `opam config env`
ocaml
Update:
Sometimes brewed opam can fail with Illegal Instruction, in that case you need to reinstall opam from sources:
brew reinstall --build-from-source opam
Also, you need a working toolchain, i.e., compiler, autotools and other developer tools. You can try to install it using brew, e.g., brew install autotools, etc. Or you can try to install xcode toolchain, including apple command line developer tools.
I had the same problem trying to install mirage, the problem is because the current directory is not in the CDPATH by default on macOS X. The posix /bin/sh will not "cd src" though can "cd ./src". The quick fix is to do the following before running opam (or just put it in your .bash_profile.
export CDPATH=.
opam install WHATEVER
While installing utop via opam on my ArchLinux laptop, I got the following message:
$ opam install utop
The following actions will be performed:
- install camomile.0.8.5 [required by utop]
- install zed.1.3 [required by utop]
- install lambda-term.1.6 [required by utop]
- install utop.1.14
4 to install | 0 to reinstall | 0 to upgrade | 0 to downgrade | 0 to remove
Do you want to continue ? [Y/n]
=-=-= Installing camomile.0.8.5 =-=-=
Applying cmxs.patch.
[ERROR] Due to some errors while processing camomile.0.8.5, the following actions will NOT proceed:
- install utop.1.14
- install lambda-term.1.6
- install zed.1.3
===== ERROR while installing camomile.0.8.5 =====
Could not get the source for camomile.0.8.5:
# opam-version 1.1.1
# os linux
Patch file "/home/sinan/.opam/system/build/camomile.0.8.5/cmxs.patch" not found.
'opam install utop' failed.
Trying to install camomile by itself also gives the same error. This seems to be related to commit 672e44e which carried over to the opam repository as cmxs.patch. I am not sure where things break so that opam tries to build without the patch file.
I tried downloading, and putting cmxs.patch in the reported location, but, of course, that directory gets clobbered the next time I try to install via opam.
How should I proceed?
I would have preferred to have been able to fix the underlying problem, but, in the end, downloading the contents of the cmxs.patch file, adding it to the already downloaded ~/.opam/archives/camomile.0.8.5+opam.tar.gz archive, and then issuing
$ opam install camomile
worked.
After that, opam install utop went without a hitch as well.
For your reference, I have:
$ opam --version
1.1.1
$ cat .opam/repo/default/repo
upstream: "https://github.com/ocaml/opam-repository/tree/master/"
browse: "https://opam.ocaml.org/pkg/"
I'm trying to install the uri package for Opam but I keep running in to this error.
==== ERROR [while installing uri.1.3.8] ====
# opam-version 0.9.6 (latest-103-g955b7ca)
# os linux
# command ocaml setup.ml -configure --prefix /root/.opam/system
# path /root/.opam/system/build/uri.1.3.8
# exit-code 1
# env-file /root/.opam/system/build/uri.1.3.8/uri-ffb3fd.env
# stdout-file /root/.opam/system/build/uri.1.3.8/uri-ffb3fd.out
# stderr-file /root/.opam/system/build/uri.1.3.8/uri-ffb3fd.err
### stderr ###
ocamlfind: Package `compiler-libs.toplevel' not found
W: Field 'pkg_compiler_libs_toplevel' is not set: Command ''/root/.opam/system/bin/ocamlfind' query -format %d compiler-libs.toplevel > '/tmp/oasis-85d951.txt'' terminated with error code 2
E: Cannot find findlib package compiler-libs.toplevel
E: Failure("1 configuration error")
'opam install uri' failed.
I'm pretty new to Ocaml and the Opam repo. I really have no idea what is going wrong. I am running Ubuntu 12.04 and have Ocaml 3.12.1 installed.
Thanks for any insight you can provide!
I just installing uri under 3.12.1 without any issues.
3.12.1 is under your system ocaml compiler, right? and you probably installed ocaml via aptitude? In which case you need to also install ocaml-compiler-libs. There are a number of other optional packages for OCaml that are usually needed and may run into in the future --camlp4-extra is another that I see missed and oft needed. A maximal list is here.
I would also upgrade OPAM, since there were some changes to the uri package only two days ago. opam update; opam upgrade. This will require some re-compilation, and make sure you switched to the correct compiler.
The package "compiler-libs.toplevel" is missing. If I remember right, it's shipped together with ocaml and is available only since version 4.0.
Either install an older version of uri or update your compiler to 4.0. For details look here