Having problems getting OPAM to install packages

opam

#1

Hi, I’m a complete OCaml noob here. I’m reading the book Real World OCaml and am getting my dev environment setup.

I’ve installed OCaml and OPAM via homebrew. When I try to install merlin, core, and utop I get a bunch of errors saying that the installation failed at jbuilder build … Below is a list of those errors I get when installing core.

[ERROR] The compilation of ocaml-migrate-parsetree failed at “jbuilder build -p ocaml-migrate-parsetree -j 4”.
[ERROR] The compilation of ppx_traverse_builtins failed at “jbuilder build --only-packages ppx_traverse_builtins --root . -j 4 @install”.
[ERROR] The compilation of sexplib failed at “jbuilder build -p sexplib -j 4”.
[ERROR] The compilation of spawn failed at “jbuilder build -p spawn -j 4”.
[ERROR] The compilation of ocaml-compiler-libs failed at “jbuilder build --only-packages ocaml-compiler-libs --root . -j 4 @install”.
[ERROR] The compilation of jane-street-headers failed at “jbuilder build -p jane-street-headers -j 4”.
[ERROR] The compilation of topkg failed at “ocaml pkg/pkg.ml build --pkg-name topkg --dev-pkg false”.

I’m not sure what steps I’ve missed. The exact steps I took were:

  • brew install ocaml
  • brew install opam
  • opam init
  • opam install merlin, core, utop

#2

After digging around it looks like I forgot the eval (opam config env) step. Looks like everything’s installing now. Sorry to have wasted anyone’s time that read this.


#3

opam install merlin, core, utop

There shouldn’t be any commas here.

After digging around it looks like I forgot the eval (opam config env) step. Looks like everything’s installing now.

The eval is needed to run the OCaml tools yourself, but opam install ... should do the install in the correct environment by itself, so I’m not sure why it didn’t work.


#4

Is it really enforced by OPAM that all the commands are called with the correct environment? Because I saw myself lots of cases when an installation fails when the environment is not activated. I was considering (and still am) those packages as broken, and always suggest people activating the environment before the install command.


#5

There is currently a known bug with opam compiled with OCaml 4.05.0 that causes it to not bind the right environment. That’s being addressed at the moment, and aside from this issue it should be the case that opam will call commands with the right environment for the active switch.


#6

@jeramyRR You might want to mark your question as [SOLVED] and edit your original post to indicate that. Or even delete it.


#7

Please don’t. That makes your question unusable for any future visitors or people stumbling over it via Google. I would even argue that a [SOLVED] tag is not great since even when the OP marks a thread as solved a better solution might still crop up.


#8

What better solution do you see possibly appearing?


#9

I do not see marking threads as “solved” as a problem that needs a solution in general. But we’re getting quite off-topic here.