fix(odoc): handle build-dir cmti paths in @doc-new fallback (#15290)#15293
Open
Alizter wants to merge 2 commits into
Open
fix(odoc): handle build-dir cmti paths in @doc-new fallback (#15290)#15293Alizter wants to merge 2 commits into
Alizter wants to merge 2 commits into
Conversation
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
approved these changes
Jul 2, 2026
shonfeder
left a comment
Member
There was a problem hiding this comment.
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 |
Member
There was a problem hiding this comment.
I guess this needs to be updated?
Collaborator
Author
There was a problem hiding this comment.
Yes, this prose will need to be updated.
| @@ -0,0 +1,55 @@ | |||
| Reproduction for https://github.com/ocaml/dune/issues/15290 | |||
Member
There was a problem hiding this comment.
I guess this is now a regression test, rather than a repro?
| 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 |
Member
There was a problem hiding this comment.
Is this the right/expected outcome? Some remarks explaining what this is demonstrating would be helful.
Collaborator
Author
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #15290.
Odoc_new.modules_of_dirlisted cmti files viaFs_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>, soas_outside_build_dir_exnraised aCode_errorand aborted the build.Switching to
Fs.dir_contents(already used elsewhere, e.g. inFindlib.Findlib_dir) handles both cases: it watches outside-build paths viaFs_memo, and for inside-build paths it waits onBuild_system.build_dirso 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-cleandune build @doc-newoutput.Test plan
dune runtest test/blackbox-tests/test-cases/pkg/doc-new-with-locked-lib.tdune build @check @fmt @runtest