Dune looking for filenames with strange capital letters

Hello,

I have the following dune file :

(library
 (public_name OTP)
 (libraries cryptokit base32 unix qrc stdint)
 (name OTP))

(env
 (dev
  (flags (:standard -w +42 -warn-error -32 -warn-error -33) ))
  (release
  (ocamlopt_flags (:standard -O3))))

When I build the project with the dev environment, it builds fine. But whith the relase environment, I have a strange error :

PS H:\OCaml\OTP> opam exec -- dune build --release
(cd _build/default && C:\Users\XXX\AppData\Local\opam\default\bin\ocamlc.opt.exe -w -40 -w -49 -nopervasives -nostdlib -g -bin-annot -bin-annot-occurrences -I lib/.OTP.objs/byte -no-alias-deps -o lib/.OTP.objs/byte/oTP.cmo -c -impl lib/oTP.ml-gen)
File "lib/oTP.ml-gen", line 1:
Error: Could not find the .cmi file for interface lib/oTP.mli.

there should not be an oTP.mli but an otp.mli file instead. I have a simple library project with two files : otp.ml and otp.mli (and a test_OTP.ml)

Is this a windows issue with dune/opam ?

Ok,

It looks like I had to compile like so instead :

opam exec -- dune build --profile release

The library name is derived from the module name, and the module name is derived from the file name. If the module name is OTP, then the file name has to be either OTP.ml or oTP.ml since the compiler automatically uppercases the first letter of the file name. If you name the library otp then the file name can be otp.ml and the module name will be Otp.

Thanks, that helps. So what is the practice concerning the naming of libraries ? Using the same name as modules (with a capital letter in front) or using lower case everywhere ?

As far as I’ve seen, library names are always lower-cased.

Yes, the convention is lower-cased. But the convention is quite ambiguous whether dashes or underscores are separators. Almost all PPX-es use underscores, yet the majority of other packages seem to use dashes.

Instead of the insider baseball / tribal knowledge, I’d encourage just re-using the same casing for the module name, library name and opam package name. That way the users of your library have one less reason to complain about how unnecessarily complicated OCaml is. Example: index (MlFront_ZipFile.index)

Just please don’t use mixed case, like oUnit, for your module filenames.