This points me in the right direction actually. I had no plans to upload a project (not library) to opam, but dune
is giving me a similar error. The difference here is…
let of_string x =
match
OpamStd.String.fold_left (fun acc c ->
if acc = Some false then acc else match c with
| 'a'..'z' | 'A'..'Z' -> Some true
| '0'..'9' | '-' | '_' | '+' -> acc
| _ -> Some false)
None x
with
| Some false ->
failwith
(Printf.sprintf "Invalid character in package name %S" x)
| None ->
failwith
(Printf.sprintf "Package name %S should contain at least one letter" x)
| Some true ->
x
in which dune
does not allow even using dune build
if a name is not a valid name for an opam library. So using example abugida characters from above…
$ dune init project แมว
dune: NAME argument: expected a valid dune atom
Usage: dune init project [OPTION]… NAME [PATH]
Try 'dune init project --help' or 'dune --help' for more information.
or even manually making the dune-project
file with string-quoted names
$ dune build
File "dune-project", line 19, characters 7-45:
19 | (name "\224\185\129\224\184\161\224\184\167")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: "\224\185\129\224\184\161\224\184\167" is an invalid opam package
name.
Package names can contain letters, numbers, '-', '_' and '+', and need to
contain at least a letter.
Hint: p_________ would be a correct opam package name
OR if trying to have the project name use non US-ASCII, but the package name needs to (Romanization via ISO_11940-2) for opam compat for reasons I don’t personally understand as someone new to the ecosystem
$ dune build
File "dune-project", line 18, characters 0-161:
18 | (package
19 | (name "maeo")
20 | (synopsis "A short synopsis")
21 | (description "A longer description")
22 | (depends ocaml dune)
23 | (tags
24 | (topics "to describe" your project)))
Error: when a single package is defined, it must have the same name as the
project name: แมว
By the way you can perfectly create projects with non US-ASCII characters, it’s just that if you want to publish it with opam
you will need an ASCII rendering of its name.
Should this then be considered a bug in dune
??