Tyxml: problem while loading the library in the Toplevel

I’m just trying to load Tyxml in the Toplevel to fine-tune some values.
And I get the following error.

It’s weird. What triggers loading in the Toplevel of ocamltoplevel.cma, while it’s not supposed to be done: "The ocamltoplevel.cma library from compiler-libs cannot be loaded inside the OCaml toplevel".

What should I look for iin order to fix that?

#  #require "tyxml";;
/home/test/.opam/4.07.01/lib/seq: added to search path
/home/test/.opam/4.07.01/lib/re: added to search path
/home/test/.opam/4.07.01/lib/re/re.cma: loaded
/home/test/.opam/4.07.01/lib/bytes: added to search path
/home/test/.opam/4.07.01/lib/uchar: added to search path
/home/test/.opam/4.07.01/lib/uutf: added to search path
/home/test/.opam/4.07.01/lib/uutf/uutf.cma: loaded
/home/test/.opam/4.07.01/lib/tyxml/functor: added to search path
/home/test/.opam/4.07.01/lib/tyxml/functor/tyxml_f.cma: loaded
/home/test/.opam/4.07.01/lib/ocaml/compiler-libs: added to search path
/home/test/.opam/4.07.01/lib/ocaml/compiler-libs/ocamlcommon.cma: loaded
/home/test/.opam/4.07.01/lib/ocaml/compiler-libs/ocamlbytecomp.cma: loaded
/home/test/.opam/4.07.01/lib/ocaml/compiler-libs/ocamltoplevel.cma: loaded
Exception:
Invalid_argument
 "The ocamltoplevel.cma library from compiler-libs cannot be loaded inside the OCaml toplevel".
/home/test/.opam/4.07.01/lib/tyxml/top: added to search path
/home/test/.opam/4.07.01/lib/tyxml/top/tyxml_top.cma: loaded
Exception: Typetexp.Error (_, _, _).
/home/test/.opam/4.07.01/lib/tyxml: added to search path
/home/test/.opam/4.07.01/lib/tyxml/tyxml.cma: loaded

It’s a known (but still unsolved) issue, look here for a workaround.

Thanks.
I was stuck with several problems of that kind these days and this workaround really helps me.

FYI, I also get the same problem with OCaml 4.08.1 .
But I can load tyxml in the Toplevel with OCaml 4.05.0 .

The problem is that tyxml's toplevel library META file has this line:

 requires = "compiler-libs.toplevel"

and it should not, I added some comments in @pveber’s issue.

2 Likes

Thanks @dbuenzli, that was a tricky one!

Thanks.

For my understanding, it should be those two files:

1/ https://github.com/ocsigen/tyxml/blob/4.3.0/implem/top/dune

(library
(name tyxml_top)
(public_name tyxml.top)
(wrapped false)
(synopsis "Toplevel printers for HTML, SVG and XML")
(libraries compiler-libs.toplevel))

2/ https://github.com/ocsigen/tyxml/blob/4.3.0/META.tyxml.template

# JBUILDER_GEN
requires(byte, toploop) += "tyxml.top"

And the winning workaround Toplevel loading sequence for tyxml is (Ocaml 4.07.1 and 4.08.0):

Topfind.don't_load ["tyxml.top"];;
Topfind.don't_load ["compiler-libs.toplevel"];;
#require "tyxml";;

Ok: 6 modules are loaded:

lib/re/re.cma
lib/uutf/uutf.cma
lib/tyxml/functor/tyxml_f.cma
lib/ocaml/compiler-libs/ocamlcommon.cma
lib/ocaml/compiler-libs/ocamlbytecomp.cma
lib/tyxml/tyxml.cma

Thanks again.

1 Like