Skip to content

Internal error with (include_subdirs qualified) and directories having illegal module names #7600

@Niols

Description

@Niols

Expected Behavior

I would expect that a project using (include_subdirs qualified) with a layout such as this one (note the directory bar-baz):

./
├── dune-project
└── src/
    ├── bar-baz/
    ├── dune
    └── foo.ml

would either:

  • compile fine, ignoring the directory in question,
  • fail gracefully, recommending a workaround.

(Actually, I would also expect this workaround to be (data_only_dirs bar-baz) but this does not fix anything.)

Actual Behavior

$ dune exec src/foo.exe
Internal error, please report upstream including the contents of _build/log.
Description:
  ("Invalid Module_name.t", { s = "bar-baz" })
Raised at Stdune__code_error.raise in file
  "otherlibs/stdune/src/code_error.ml", line 11, characters 30-62
Called from Stdlib__List.rev_map.rmap_f in file "list.ml", line 103,
  characters 22-25
Called from Stdune__list.map in file "otherlibs/stdune/src/list.ml"
  (inlined), line 5, characters 19-33
Called from Dune_rules__ml_sources.make.(fun) in file
  "src/dune_rules/ml_sources.ml", line 459, characters 23-62
Called from Stdlib__List.fold_left in file "list.ml", line 121, characters
  24-34
Called from Dune_rules__ml_sources.make in file
  "src/dune_rules/ml_sources.ml", line 457, characters 8-1023
Called from Fiber__scheduler.exec in file "otherlibs/fiber/src/scheduler.ml",
  line 73, characters 8-11
-> required by ("<unnamed>", ())
-> required by ("<unnamed>", ())
-> required by ("load-dir", In_build_dir "default/src")

I must not crash.  Uncertainty is the mind-killer. Exceptions are the
little-death that brings total obliteration.  I will fully express my cases. 
Execution will pass over me and through me.  And when it has gone past, I
will unwind the stack along its path.  Where the cases are handled there will
be nothing.  Only I will remain.

Reproduction

  1. Get yourself a development environment with Dune 3.7.1. I use:

    $ nix shell github:nixos/nixpkgs/0a0f9e92d#ocamlPackages.{ocaml,dune_3,findlib}
    
  2. Create a project, eg. this one, which I detail here:

    $ cat dune-project
    (lang dune 3.7)
    (name foo)
    $ cat src/dune
    (include_subdirs qualified)
    (executable (name foo))
    $ cat src/foo.ml
    let () = Format.printf "foo@."
  3. Check that everything works fine:

    $ dune exec src/foo.exe
    foo
  4. Create an offending directory

    $ mkdir src/bar-baz
    
  5. See that it fails:

    $ dune exec src/foo.exe
    ...the error above...
  6. (Optional) Add (data_only_dirs bar-baz) to src/dune and check that it fails again:

    $ echo '(data_only_dirs bar-baz)' >> src/dune
    $ dune exec src/bar-baz
    ...the error above...

Specifications

  • Version of dune (output of dune --version): 3.7.1
  • Version of ocaml (output of ocamlc --version): 4.14.1
  • Operating system (distribution and version): NixOS unstable on x86_64-linux, in a Nix shell with
    $ nix shell github:nixos/nixpkgs/0a0f9e92d#ocamlPackages.{ocaml,dune_3,findlib}
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions