fix(utop): accept absolute paths to workspace directories
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
DIRtoArg.Workspace_path. That converter doesn't exist yet, and a cmdliner conv can't localize at parse time since localization needsBuild.build_dir, which is only set afterCommon.init. I went with the inline localization thatexecandruntestalready use. Happy to extract a sharedArg.Workspace_pathfor #15109/#15110 if thats preferred. Should that live in this PR or a follow-up? - An absolute path pointing into
_buildwould localize to an in-build path.exechandles that throughPath.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.