ocaml
ocaml copied to clipboard
Library not found "oUnit", but renaming to "ounit" fixes it
When I try running tests dune throws an error "Library not found "oUnit", but renaming it to "ounit" in dune file fixes it.
I'm on MacOS. Dune version is 1.11.3 Opam - 2.0.5.
I can say that if I change "oUnit" to "ounit" in the file "dune", make
will fail.
If I change "oUnit" to "ounit2" in the file "dune", make
will succeed.
This is Linux, dune --version
gives 1.11.3 and opam --version
gives 2.0.4.
I'm not sure why "oUnit" would work for some and not for others.
I asked around, and this is perhaps due to opam
and ocamlfind
not always agreeing.
Looking at the description for the package "ounit", it says:
This is a transition package, ounit is now ounit2
I don't know if this means we should refer to the package "ounit2" instead.
If this works for both you, me and @marionebl, then we could consider making this change to avoid any similar problems for other users. Still, I would like to understand fully why this error occurs.
@sshine I tried ounit2
and it fails for me.
$ dune --version
1.11.0
$ opam --version
2.0.1
$ uname
Linux
Checking inside our dev container I get the following error when replacing oUnit
with ounit
:
$ dune runtest
File "dune", line 3, characters 17-22:
3 | (libraries base ounit))
^^^^^
Error: Library "ounit" not found.
Hint: try: dune external-lib-deps --missing @runtest
This is consistent with ocamlfind
:
$ ocamlfind query ounit
ocamlfind: Package `ounit' not found
$ ocamlfind query oUnit
/home/opam/.opam/4.07/lib/oUnit
@marionebl: Does ounit2
work for you? It works here.
@troglotit: I'd very much like to know why this fails on your system. As I neither do active OCaml development nor own a Mac, I am not in a good position to find out. I've asked around on IRC, and the few respondents didn't recognize this scenario, but they were all on Linux.
I think our next hope is to either debug your system (see if there is some special case in your OCaml setup), or ask on StackOverflow. Perhaps we can start by uncovering how you installed OCaml? Was this through OPAM?
Yes, it was via OPAM, which was installed via Homebrew.
@troglotit I got a similar issue caused by a mismatch between the current Ocaml version in opam and the system wide one. eval `opam env`
fixes it for me.
@nguyendv Thanks, but, unfortunately, it doesn't work for me. I think I don't even have a system-wide OCaml installation though.
For anyone in 2023 that is new to OCaml (like myself) and is encountering this error when trying to run make
in the exercise folder and found this issue by googling the error:
I was able to fix this by running opam install ounit2
.