Unbound module Stdllib

I’m trying to understand why a friend cannot install unison, and it boiled down to a broken ocaml install. Here is what he did (on a Debian stable)

git clone https://github.com/ocaml/ocaml.git
cd ocaml/                                   
git branch                                  
git checkout remotes/origin/4.08            
make world.opt -j                           
sudo make install                           

but then when he launches ocaml he gets

          OCaml version 4.08.2+dev0

  File "command line", line 1:
  Error: Unbound module Stdlib

I’ve advised him to use opam, but I’m curious where such behavior could come from. Any idea?

It’s a bit unclear whether you reproduced that or not.

In any case it seems ocaml cannot determine the OCaml library directory. It would be interesting to have a look at the output of:

ocamlc -config | grep standard
env | grep "OCAMLLIB" 

For example it’s easy to reproduce the same error message by setting OCAMLLIB to /dev/null:

> OCAMLLIB=/dev/null ocaml
        OCaml version 4.09.0

File "command line", line 1:
Error: Unbound module Stdlib

Check also the variable CAMLLIB which has the same effect.

My guess is that he has debian stable’s system ocaml (which seems to be ocaml-4.05) also installed. In any event, using opam to provide ocaml-4.08 should solve it. Uninstalling debian’s ocaml package would also be a good idea, irrespective of that.

@cvine does debian stable set OCAMLLIB ?

That would explain the problem, Stdlib is new in 4.08 so the newly installed toplevel doesn’t find it. With a version pre 4.08 magic number errors would likely have been output.

No idea, I don’t use debian. It was the fact that Stdlib was reported missing which made me think of clashing compilers. In any event, having two versions of the ocaml compiler installed, one in the /usr prefix and one in the /usr/local prefix, is asking for trouble, if that is what has happened. The person concerned would not, I hope, try the same thing with gcc/g++.

Leaving it to opam will solve these problems as it sets up multiple compilers for you correctly.

One quick option to build and run it is to use Docker. Unison has a Dockerfile.

Thank you all for the suggestions. Here are what his machine is showing:

       $ ocamlc -config | grep standard
       standard_library_default: /usr/local/lib/ocaml
       standard_library: /usr/local/lib/ocaml
       $ env | grep "OCAMLLIB" 

       $ env | grep "CAMLLIB" 

and there is no other ocaml installed.

I will still suggest that he installs opam, but I’m surprised this error is happening.

So am I. That looks right (assuming ./configure without specifying --prefix uses /usr/local/lib/ocaml).

What about:

ls -l /usr/local/lib/ocaml/stdlib.cmi 

This was the cause of the problem:

$ ls -l /usr/local/lib/ocaml/stdlib.cmi
ls: cannot access '/usr/local/lib/ocaml/stdlib.cmi': Permission denied
$ sudo ls -l /usr/local/lib/ocaml/stdlib.cmi 
-rw-rw-r-- 1 root staff 33942 Feb  5 16:43 /usr/local/lib/ocaml/stdlib.cmi

the sudo make install does not seem to set the permissions correctly.

These permissions look right no ? Is it the ocaml dir that is not traversable ?

Regarding error reporting by ocaml it’s a pity it doesn’t report a better error message. I’m almost sure this can be blamed on use of Sys.file_exists which does not raise on permission errors but returns false on these which is a very bad idea.

It seems so:

$ ls -l /usr/local/lib
drwxr-s--- 8 root staff 20480 Feb  5 16:43 ocaml/

It seems ocaml uses a simple mkdir -p to create the directory which is modified by the user umask.

Maybe it should rather use install -d .

If that’s an unmodified stock system it may be worth opening an issue upstream.

I’m pretty sure this is an unmodified system. Changing the permissions solved the issue.