OCamlPro / ocaml-top

A simple cross-platform OCaml code editor built for top-level evaluation.
http://typerex.org/ocaml-top.html
GNU General Public License v3.0
64 stars 8 forks source link

ocaml is not a bytecode executable file (OSX) #55

Open dcharkes opened 8 years ago

dcharkes commented 8 years ago

Opening the editor gives me the following editor:

Fatal error: the file '/Users/myusername/.opam/system/bin/ocaml' is not a bytecode executable file
.
**********************************************

Error: ocaml process not operational.
Please check your installation and parameters
**********************************************

Running /Users/myusername/.opam/system/bin/ocaml in the terminal gives me a working OCaml REPL.

Why can the editor not use the ocaml executable?

dcharkes commented 8 years ago

Issue is the OCaml version, I was using 4.03.0.

Workaround: opam switch 4.01.0 opam install ocaml-top

mpodell commented 8 years ago

Installed OCaml and OPAM via Homebrew today: ocaml: stable 4.02.3 (bottled) opam: stable 1.2.2 (bottled) encountered same problem. Workaround worked for me. Thx @dcharkes

mpodell commented 8 years ago

However, I could not get Core to load. It does not look like ocaml-top reads the .ocamlinit file. By explicitly adding at the prompt:

use "topfind";;

camlp4o;;

thread;;

require "core";;

require "core.top";;

require "core.syntax";;

I can then open Core.Std

Also, I am able to get ocaml-top to launch with a operational ocaml process under 4.02.3 by making sure my path is /Users/$USER/.opam/4.02.3/bin:$PATH instead of /Users/$USER/.opam/system/bin:$PATH (which is what my path was when I was originally having the problem described by @dcharkes above).

dcharkes commented 8 years ago

I got it to work with 4.02.1as well. So, it looks like it's a 4.03.0 specific problem.

dcharkes commented 8 years ago

@mpodell to load a module I passed an argument to the ocaml toplevel: ocaml-top --- -I ~/.opam/4.02.3/lib/adapton/.

Your solution

#use "topfind";;
#require "adapton";;
open Adapton;;

also works, but you can not use #use and #require if you want to compile the code (stackoverflow).

infinity0 commented 8 years ago

This problem also exists with 4.02.3 Debian. The error is "correct" in the sense that .opam/system/bin/ocaml is indeed not bytecode executable. Not sure why this should block ocaml-top from using it, though.

AltGr commented 8 years ago

Sorry for replying so late. By default, ocaml-top will try to run ocamlrun ocaml -- which will only work with a bytecode version of the ocaml exec. Distributions apparently moved to have ocaml as a custom binary rather than pure bytecode, which break this.

Workaround: use ocaml-top -ocaml ocaml

The reason for originally running through ocamlrun has to do with Windows support, which makes process control very hard. When calling ocaml directly, there would be a new process spawned for ocamlrun, and, processes being non-hierarchichal, we would lose the handle on the child ocaml process. That took me a while to figure out at the time. There wasn't at the moment a reason to do differently on other OSes, but we could now discriminate to run through ocamlrun or not.