Summary
To save your time, let’s jump to the conclusion:
OCaml’s default toplevel / interactive shell probably has some render issues. If you try:
4nji@Gra ~/d/o/pdf_copypaste> ocaml
OCaml version 5.0.0
Enter #help;; for help.
# Unix.sleep 1;;
You’ll get:
Alert ocaml_deprecated_auto_include:
OCaml's lib directory layout changed in 5.0. The unix subdirectory has been
# Unix.sleep 1;;ded to the search path, but you should add -I +unix to the
command-line to silence this alert (e.g. by adding unix to the list of
libraries in your dune file, or adding use_unix to your _tags file for
ocamlbuild, or using -package unix for ocamlfind).
Error: Reference to undefined global `Unix'
#
Notice that the 3rd line of Alert message was overwritten by my previous input, causing confusion.
You’ll need a window-sized terminal (with <= 65 columns) which has a rather small screen buffer to reproduce the bug.
(end of summary)
Hello! A very random topic / issue / question here. Could be a bug tho.
~/ocaml $ rlwrap ocaml
OCaml version 5.1.0+dev1-2022-06-09
Enter #help;; for help.
# Unix.sleep 1;;
Alert ocaml_deprecated_auto_include:
OCaml's lib directory layout changed in 5.0. The unix subdirectory has been
automatically added to the search path, but yo# Unix.sleep 1;;+unix to the
command-line to silence this alert (e.g. by adding unix to the list of
libraries in your dune file, or adding use_unix to your _tags file for
ocamlbuild, or using -package unix for ocamlfind).
Error: Reference to undefined global `Unix'
Hint: This means that the interface of a module is loaded, but its implementation is not.
Found /data/data/com.termux/files/usr/lib/ocaml/unix/unix.cma
in the load paths. Did you mean to load it using #load "unix.cma"
or by passing it as an argument to the toplevel?
#
Then I Ctrl-D to terminate the process and changed the columns & rows of my terminal, then do the same thing again
~/ocaml $ rlwrap ocaml
OCaml version 5.1.0+dev1-2022-06-09
Enter #help;; for help.
# Unix.sleep 1;;
Alert ocaml_deprecated_auto_include:
OCaml's lib directory layout changed in 5.0. The unix subdirectory has been
# Unix.sleep 1;;ded to the search path, but you should add -I +unix to the
command-line to silence this alert (e.g. by adding unix to the list of
libraries in your dune file, or adding use_unix to your _tags file for
ocamlbuild, or using -package unix for ocamlfind).
Error: Reference to undefined global `Unix'
Hint: This means that the interface of a module is loaded, but its implementation is not.
Found /data/data/com.termux/files/usr/lib/ocaml/unix/unix.cma
in the load paths. Did you mean to load it using #load "unix.cma"
or by passing it as an argument to the toplevel?
What am I missing here? Is this a random bug?
update
I tried this on my macOS with OCaml 5.0.0, I think it’s officially a bug now
4nji@Gra ~> rlwrap ocaml
OCaml version 5.0.0
Enter #help;; for help.
# Unix.sleep 1;;
Alert ocaml_deprecated_auto_include:
OCaml's lib directory layout changed in 5.0. The unix subdirectory has been
# Unix.sleep 1;;ded to the search path, but you should add -I +unix to the
command-line to silence this alert (e.g. by adding unix to the list of
libraries in your dune file, or adding use_unix to your _tags file for
ocamlbuild, or using -package unix for ocamlfind).
Error: Reference to undefined global `Unix'
#
Both Android (Termux) and macOS Big Sur have the same issue