Fatal error: cannot load shared library dllext_stubs

So, I want to give ocamldebug a shot.
Using latest Mac and OCaml 5.3.0:

nojaf@nojaf-mbp rescript % dune build
nojaf@nojaf-mbp rescript % ocamldebug _build/default/analysis/bin/main.bc            
        OCaml Debugger version 5.3.0

(ocd) break @Main 92
Loading program... Fatal error: cannot load shared library dllext_stubs
Reason: dlopen(dllext_stubs.so, 0x000A): tried: 'dllext_stubs.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSdllext_stubs.so' (no such file), '/usr/lib/dllext_stubs.so' (no such file, not in dyld cache), 'dllext_stubs.so' (no such file)
(ocd) 

Where should dllext_stubs.dylib be coming from?

You can use the environment variable CAML_LD_LIBRARY_PATH to specify where to look up shared libraries containing native stubs (see OCaml - The runtime system (ocamlrun)). Dune places the stubs of native (public) libraries in _build/install/default/lib/stublibs.

Did you try dune exec -- ocamldebug ...?

Cheers,
Nicolas

I don’t seem to have any files there:

nojaf@nojaf-mbp rescript % ls _build/install/default/lib/stublibs
ls: _build/install/default/lib/stublibs: No such file or directory
nojaf@nojaf-mbp rescript % dune exec -- ocamldebug /Users/nojaf/Projects/rescript/_build/default/analysis/bin/main.bc
        OCaml Debugger version 5.3.0

(ocd) break @Main 92
Loading program... Fatal error: cannot load shared library dllext_stubs
Reason: dlopen(dllext_stubs.so, 0x000A): tried: 'dllext_stubs.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSdllext_stubs.so' (no such file), '/usr/lib/dllext_stubs.so' (no such file, not in dyld cache), 'dllext_stubs.so' (no such file)
(ocd) 

CAML_LD_LIBRARY_PATH rings a bell, but I have no clue where to point it.

Hard to say with the available information. You may want to make your code available somewhere in order to get better advice.

Cheers,
Nicolas

Yeah, I understand it is not much to go on.
The code is available on GitHub - rescript-lang/rescript: ReScript is a robustly typed language that compiles to efficient and human-readable JavaScript.

It has a few project and I’m trying to debug the analysis project.
Maybe I’m missing some dune flags

I don’t have a Reason toolchain to try it, but a quick look at the source indicates that the missing stubs are those of the library compiler/ext. You may want to look into _build/default/compiler/ext to see if you find your missing shared library.

Cheers,
Nicolas

The Reason toolchain isn’t required here. ReScript compiler is in OCaml, but doesn’t use Reason.
Could I just be missing a dependency? I think at some point it was inside _build/default/compiler/ext. Seems no longer to be the case.

Update:

ls /Users/nojaf/Projects/rescript/_build/default/compiler/ext/*.so
/Users/nojaf/Projects/rescript/_build/default/compiler/ext/dllext_stubs.so

Using CAML_LD_LIBRARY_PATH=/Users/nojaf/Projects/rescript/_build/default/compiler/ext:

Now leads to

Loading program... Fatal error: cannot load shared library dllbase_internalhash_types_stubs
Reason: dlopen(dllbase_internalhash_types_stubs.so, 0x000A): tried: 'dllbase_internalhash_types_stubs.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSdllbase_internalhash_types_stubs.so' (no such file), '/usr/lib/dllbase_internalhash_types_stubs.so' (no such file, not in dyld cache), 'dllbase_internalhash_types_stubs.so' (no such file)
(ocd) %           

Okay, I figured it out. I need to append that _build/default/compiler/ext path to CAML_LD_LIBRARY_PATH

export CAML_LD_LIBRARY_PATH="$CAML_LD_LIBRARY_PATH:_build/default/compiler/ext"