Utop : not a bytecode executable file

I have installed opam and ocaml through Homebrew. When I run which Ocaml I get /Users/me/.opam/system/bin/ocaml

which opam however gives /usr/local/bin/opam. Is this normal? If so running utop gives me the error /Users/me/.opam/system/bin/utop' is not a bytecode executable file…Can anyone lend some help as to how to go about troubleshooting this?

Running which utop also gives /Users/me/.opam/system/bin/utop

Currently Running MacOS High Sierra. This is happening after an upgrade

You don’t specify how you installed opam and the like. Homebrew perhaps? Regardless, that’s important information. You’re also using a system switch, rather than an opam created switch, which isn’t really recommended.

See if this works for you:

$ opam switch 4.07.1
$ eval $(opam config env)
$ opam install utop
$ utop

Thank you for the reply. Unfortunately running opam switch 4.07.1 results in an error: [ERROR] No switch 4.07.1 is currently installed. Did you mean ‘opam switch
create 4.07.1’?
Installed switches are:
- system

That’s fine, just follow the error messages.
opam switch create 4.07.1

Running opam switch create 4.07.1:
[ERROR] No compiler matching ‘4.07.1’ found, use ‘opam switch list-available’
to see what is available, or use ‘–packages’ to select packages
explicitly.

running opam switch list-available gives: Listing available compilers from repositories: default

No matches found

Yes it was all Homebrew but I did try a MacPorts install that is now gone.

Hmm… perhaps try:

opam update
opam switch create ocaml-base-compiler.4.07.1
[ERROR] No compiler matching 'ocaml-base-compiler.4.07.1' found, use 'opam
        switch list-available' to see what is available, or use '--packages' to
        select packages explicitly.

That certainly is strange. It’s not finding any compilers? Try removing brew uninstall opam and try getting it directly from the opam releases page, here: https://github.com/ocaml/opam/releases/download/2.0.3/opam-2.0.3-x86_64-macos

Then extract move the file to /usr/local/bin/opam and chmod +x /usr/local/bin/opam

Could it be you forgot to do an opam init ?

I believe I have done one but could not hurt to try. Using Finder to go to /usr/local/bin/opam gives an error. It seems the directory does not exist.

I have also already ran brew uninstall opam

sudo mv <path to downloaded file> /usr/local/bin/opam
chmod +x /usr/local/bin/opam

Is this mv command supposed to create a new directory? I see opam in /usr/local/bin/ as an executable. I can once again run the opam command but utop gives the error:

Fatal error: the file '/Users/me/.opam/system/bin/utop' is not a bytecode executable file

Maybe I still need to run init now?

No, opam is an executable. I would suggest you start from scratch.

rm -rf ~/.opam
opam init --compiler ocaml-base-compiler.4.07.1
eval $(opam env)
opam install utop
utop
2 Likes

38%20PM

Thank you so much!

1 Like