This is a weird error that should not happen. The Bytes module still exists. Did you check that your environment is consistent and that you don’t have a module named Stdlib? Do you happen to use an .ocamlinit file?
No, I didn’t use it at .ocamlinit. Instead, the .ml script that invokes Bytes.get is loaded by Toploop.use_file on REPL.
One interesting observation is that, before loading the .ml file, if I simply typecheck Bytes.get on REPL and load the .ml file using Toploop.use_file on REPL then it works well.
I will reduce this code so that a reproducible code snippet can be shared.
Yes, I use opam, but the opam is locally configured (opam env prints the directory that is specific to this project).
Interestingly I can find the ./lib/ocaml/stdlib__Bytes.* from the local opam directory as well.
Hi all, I managed to reduce the program into its minimal form! It consists of these four statements on OCaml REPL 4.14.0:
my_desktop: ~/ $ ocaml
OCaml version 4.14.0
Enter #help;; for help.
# #directory "+compiler-libs";;
# #load "ocamlcommon.cma";;
# Env.fold_modules (fun s p md () -> ()) (Some (Longident.Lident "Bytes")) !Toploop.toplevel_env ();;
- : unit = ()
# Bytes.get;;
Error: The module Bytes is an alias for module Stdlib__Bytes, which is missing
opam list shows the package versions as follows:
# Packages matching: installed
# Name # Installed # Synopsis
base-bigarray base
base-threads base
base-unix base
camlp-streams 5.0.1 The Stream and Genlex libraries for use with Camlp4 and Camlp5
camlp5 8.00.03 pinned to version 8.00.03
conf-perl 2 Virtual package relying on perl
conf-perl-ipc-system-simple 3 Virtual package relying on perl's IPC::System::Simple
conf-perl-string-shellquote 3 Virtual package relying on perl's String::ShellQuote
dune 3.7.1 Fast, portable, and opinionated build system
num 1.4 The legacy Num library for arbitrary-precision integer and rational arithmetic
ocaml 4.14.0 The OCaml compiler (virtual package)
ocaml-base-compiler 4.14.0 Official release 4.14.0
ocaml-config 2 OCaml Switch Configuration
ocaml-options-vanilla 1 Ensure that OCaml is compiled with no special options enabled
ocamlfind 1.9.6 A library manager for OCaml
Note that the short answer for using compiler-libs within the REPL is to use utop-full (or another not expunged toplevel). Loading compiler-libs a second time in the REPL create two separate instances of the compiler-libs modules which invariably leads to issues.