OCaml: cannot load Core library

I’m in the process of setting up an OCaml environment for a course I’m taking which requires the Core Standard Library.

Using the following shell.nix:

with import <nixpkgs> {};

mkShell {
  buildInputs = [
    ocaml
  ] ++ (with ocamlPackages; [
    findlib
    utop
    core 
  ]);
}

I try to execute the following in utop:

#require "base";;
#require "core";;

But I end up with the following errors:

utop # #require "base";;
Cannot load required shared library dllbase_stubs.
Reason: dllbase_stubs.so: dllbase_stubs.so: cannot open shared object file: No such file or directory.

utop # #require "core";;
Error: Reference to undefined global `Base__Fieldslib'

What am I missing? This is the first time I use OCaml, so I’m a bit lost.

Cheers.

I don’t know anything about how the Ocaml packaging is done. Summoning @vbgl :slight_smile:

What version of nixpkgs are you using? It should be fixed in recent master.

Latest master does indeed fix the issue. How do I check the version of nixpkgs?

You can use nix-info to get details about your nix setup:

nix-shell -p nix-info --run "nix-info -m"

I think this issue (dynamic loading of bytecode libraries with stubs) has been addressed as part of ocamlPackages.findlib: two fixes by vbgl · Pull Request #37161 · NixOS/nixpkgs · GitHub

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 4.14.39, NixOS, 18.03.132304.45cd6090d9a (Impala)`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.0.1`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs`

So I suppose my nixpkgs is on Impala? Any case, using latest master fixes the issue.