Skip to content

fix(odoc): handle build-dir cmti paths in @doc-new fallback (#15290)#15293

Open
Alizter wants to merge 2 commits into
ocaml:mainfrom
Alizter:push-fix-15290
Open

fix(odoc): handle build-dir cmti paths in @doc-new fallback (#15290)#15293
Alizter wants to merge 2 commits into
ocaml:mainfrom
Alizter:push-fix-15290

Conversation

@Alizter

@Alizter Alizter commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #15290.

Odoc_new.modules_of_dir listed cmti files via Fs_memo.dir_contents (Path.as_outside_build_dir_exn d). For libraries installed by a lock-dir package, the cmti directory lives under _build/_private/.../target/lib/<lib>, so as_outside_build_dir_exn raised a Code_error and aborted the build.

Switching to Fs.dir_contents (already used elsewhere, e.g. in Findlib.Findlib_dir) handles both cases: it watches outside-build paths via Fs_memo, and for inside-build paths it waits on Build_system.build_dir so the locked package's install action has finished before we enumerate its modules.

Builds on top of #15292 (the cram reproduction). The test there is updated to drop the grep "Internal error" and assert the now-clean dune build @doc-new output.

Test plan

  • dune runtest test/blackbox-tests/test-cases/pkg/doc-new-with-locked-lib.t
  • dune build @check @fmt @runtest

Alizter added 2 commits June 23, 2026 12:38
Build @doc-new against a lock-dir package whose lib is exposed via a META
file only (no dune-package) and observe the as_outside_build_dir_exn crash
in Odoc_new.modules_of_dir.

Signed-off-by: Ali Caglayan <alizter@gmail.com>
)

[Odoc_new.modules_of_dir] called [Fs_memo.dir_contents] via
[Path.as_outside_build_dir_exn], which crashes when the cmti
directory lives under [_build/_private/.../target/lib] - the case
for libraries installed by lock-dir packages.

Use [Fs.dir_contents] instead: it branches on build-vs-outside and
waits on [Build_system.build_dir] for inside-build paths, so the
locked package's install action finishes before we list its modules.

Signed-off-by: Ali Caglayan <alizter@gmail.com>
@shonfeder shonfeder marked this pull request as ready for review July 1, 2026 12:12
@shonfeder shonfeder self-requested a review July 1, 2026 12:12

@shonfeder shonfeder left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test could be clearer explained, IMO, but core logic fix looks straight forward.

Comment on lines +3 to +4
Building @doc-new with package management enabled crashes when a locked
package installs a library via a META file (without a dune-package), because

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this needs to be updated?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this prose will need to be updated.

@@ -0,0 +1,55 @@
Reproduction for https://github.com/ocaml/dune/issues/15290

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is now a regression test, rather than a repro?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed.

File "fakefmt.mld", line 7, characters 0-11:
Warning: '{!modules ...}' should not be empty.
File "page-fakefmt.odoc":
Warning: Failed to lookup child page dummy

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the right/expected outcome? Some remarks explaining what this is demonstrating would be helful.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the correct output as this is coming straight from odoc. There is probably a better way we can assert that odoc ran other than capturing its output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Internal error with "dune build --pkg=enable @doc-new"

2 participants