Repository navigation
test: dune utop absolute-path crash (#15108) - #15116
Merged
Merged
Conversation
3 of 13 tasks
Alizter
force-pushed
the
push-yptuyqrprxry
branch
from
June 10, 2026 17:12
5683b91 to
5bff500
Compare
Alizter
force-pushed
the
push-yptuyqrprxry
branch
from
June 10, 2026 18:01
5bff500 to
18626c3
Compare
Alizter
marked this pull request as ready for review
June 10, 2026 18:05
Alizter
force-pushed
the
push-yptuyqrprxry
branch
from
June 10, 2026 22:15
18626c3 to
b736cbd
Compare
Adds a cram test demonstrating that dune utop crashes with a Code_error when given an absolute path to a workspace directory: Common.prefix_target is a no-op for absolute strings, leaving Path.Build.relative to receive an absolute string and raise. The outside-workspace case already short-circuits via the Fpath.is_directory existence check, so it produces a clean user error today and must not regress. Tracks ocaml#15108 (sub-issue of ocaml#12230). Recorded with CR-someday Alizter for a follow-up fix that migrates the DIR argument to Arg.Workspace_path. Signed-off-by: Ali Caglayan <[email protected]>
Alizter
force-pushed
the
push-yptuyqrprxry
branch
from
June 26, 2026 13:29
b736cbd to
29763b5
Compare
Alizter
added a commit
that referenced
this pull request
Jun 29, 2026
Fixes #15108. `dune utop $PWD/lib` crashed with an internal `Code_error` while `dune utop lib` worked. `Common.prefix_target` is a no-op on absolute strings, so the absolute path reached `Path.Build.relative`, which raises on absolute input. This change localizes an absolute `DIR` argument with `Path.Expert.try_localize_external` before use. this is the same approach that `dune exec` (#12094) and `dune runtest` (#11936) already uses. A relative path still goes through `Common.prefix_target` so the run-from-a-subdirectory case is unchanged, and a part outside the workspace stays external and still produces the clean `Error: cannot find directory: ...` message. Based on @Alizter's repro in #15116, the test was flipped from asserting the crash to checking the working `foolib` output. questions I have: * The issue suggests migrating `DIR` to `Arg.Workspace_path`. That converter doesn't exist yet, and a cmdliner conv can't localize at parse time since localization needs `Build.build_dir`, which is only set after `Common.init`. I went with the inline localization that `exec` and `runtest` already use. Happy to extract a shared `Arg.Workspace_path` for #15109/#15110 if thats preferred. Should that live in this PR or a follow-up? * An absolute path pointing into `_build` would localize to an in-build path. `exec` handles that through `Path.relative_to_source_in_build_or_external`. This isn't covered by the repro or the issue's required behaviors, so I left it out for now. Let me know if you would like that included here. * I also wasnt sure if there is a preferred place for sharing this localization logic across commands instead of keeping it inline.
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.
Reproduction case for #15108.
dune utop $PWD/libcrashes with aCode_errorinstead of accepting the absolute form of the workspace-relative path that works today.