ocamlfind
ocamlfind copied to clipboard
`compiler-libs.common` being loaded again in REPL
Hello all,
I am trying to use the Env
module in compiler-libs.common (link: https://ocaml.org/p/ocaml-base-compiler/4.14.1/doc/Env/index.html) , which was expunged from the recent toplevel.
In order to use this, I am building a new REPL using ocamlmktop
which links compiler-libs to the REPL, and this resolves the issue.
However, if I load some library, e.g., camlp5
, using Topfind.load_deeply
, it loads compiler-libs.common
again, making the REPL unable to use Env
:
# Topdirs.dir_use Format.std_formatter "topfind";;
(snip)
# Topfind.load_deeply ["camlp5"];;
.../_opam/lib/ocaml/compiler-libs: added to search path
.../_opam/lib/ocaml/compiler-libs/ocamlcommon.cma: loaded <- this again loads ocamlcommon.cma
(snip)
# let x = Env.lookup_value ~use:true ~loc:Location.none Longident.(Ldot(Lident "Bytes", "get")) !Toploop.toplevel_env;;
Exception:
Env.Error
(Env.Lookup_error
({Location.loc_start =
{Lexing.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1};
loc_end =
{Lexing.pos_fname = "_none_"; pos_lnum = 0; pos_bol = 0; pos_cnum = -1};
loc_ghost = true},
<abstr>,
Env.Cannot_scrape_alias (Longident.Lident "Bytes", Path.Pident <abstr>))).
https://github.com/ocaml/ocaml/issues/12271 has more details about the error.
In order to resolve this error, I am relying on Topfind.don't_load ["compiler-libs.common"]
. It works, but it would be great if compiler-libs.common
is not loaded by default because it is already available in the toplevel.