Graphics does not install on OPAM MacOS/HomeBrew with default switch

opam

#1

I observed an unexpected behavior on installing the Graphics library.

I am using MacOS High-Sierra 10.13.6 (17G65), with Opam 2.0.0, installed with HomeBrew.

I tried to install the Graphics library on the default switch, and it failed. See the trace below. However, it installs without any problem on any other switch, for instance 4.07.0+rc1.

This was somewhat disturbing. Is there any rationale behind?

Regards,

Luc.

$ opam switch default

$ opam install graphics
The following actions will be performed:
  ∗ install graphics 1.0

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫 

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫 
[ERROR] The compilation of graphics failed at "/Users/bouge/.opam/opam-init/hooks/sandbox.sh build ocamlc -custom graphics.cma -o test".
#=== ERROR while compiling graphics.1.0 =======================================#
# context     2.0.0 | macos/x86_64 | ocaml-system.4.07.0 | https://opam.ocaml.org#bca60b0e
# path        ~/.opam/default/.opam-switch/build/graphics.1.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build ocamlc -custom graphics.cma -o test
# exit-code   2
# env-file    ~/.opam/log/graphics-92876-dd682e.env
# output-file ~/.opam/log/graphics-92876-dd682e.out
### output ###
# File "_none_", line 1:
# Error: Cannot find file graphics.cma
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫 
┌─ The following actions failed
│ λ build graphics 1.0
└─ 
╶─ No changes have been performed
<><> graphics.1.0 troubleshooting <><><><><><><><><><><><><><><><><><><><><>  🐫 
=> This package checks whether the Graphics library was compiled.

#2

If you’re using MacPorts with OPAM, you’re well advised not to use a system switch for any longer than it takes to compile a new switch. I suspect that the same is true on Homebrew.


#3

Yes. In the current version of opam 2.0.0 on brew ocaml is not even an dependency anymore, it is just required for building and testing so if you just get the precompiled version (“bottle”) then you don’t even install ocaml.


#4

hi, I have the same problem like you. can you please tell me, what the solution is? Thank you. :blush:


#5

Yes, do not use the system compiler but rather use an opam-built one:

opam switch create 4.07.1
opam install graphics