Skip to content

Remove unnecessary use of chdir#6910

Merged
kit-ty-kate merged 3 commits into
ocaml:masterfrom
NathanReb:remove-chdir
May 13, 2026
Merged

Remove unnecessary use of chdir#6910
kit-ty-kate merged 3 commits into
ocaml:masterfrom
NathanReb:remove-chdir

Conversation

@NathanReb
Copy link
Copy Markdown
Collaborator

This ports the chdir removal from #5966 as asked for in #6600.

Copy link
Copy Markdown
Member

@kit-ty-kate kit-ty-kate left a comment

Choose a reason for hiding this comment

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

The tests need to be adapted to the new API (tests/lib/patcher uses chdir)

Comment thread src/format/opamFilter.ml Outdated
@kit-ty-kate
Copy link
Copy Markdown
Member

On top of #6600, this should hopefully also fix #3171

@NathanReb NathanReb force-pushed the remove-chdir branch 2 times, most recently from 3772c88 to 3855290 Compare April 28, 2026 08:37
@NathanReb NathanReb requested a review from kit-ty-kate April 28, 2026 08:45
kit-ty-kate added a commit to kit-ty-kate/opam-publish that referenced this pull request Apr 28, 2026
@NathanReb
Copy link
Copy Markdown
Collaborator Author

NathanReb commented Apr 28, 2026

The test failures seem to all come from opam-rt builds. I guess it needs to be patched as well.

This could make us reconsider the removal of the chdir dependant API entries as this constitutes a breaking API change.

I could simply reintroduce them now that we know they're not used internally anymore but I assume the goal is to discourage their use entirely in opam so removing them feels right.

Let me know what you'd prefer here. I wonder if we could use some neat trick to deprecate them internally without the warning hitting external users, this would make for a good in between.

Edit: I forgot to hit Comment. I saw your PR on but still wanted to open the discussion on the breaking API change.

Comment thread src/format/opamFilter.mli Outdated
@kit-ty-kate
Copy link
Copy Markdown
Member

The test failures seem to all come from opam-rt builds. I guess it needs to be patched as well.

done in ocaml-opam/opam-rt#89

@NathanReb
Copy link
Copy Markdown
Collaborator Author

Any idea what's wrong with this build in particular: https://github.com/ocaml/opam/actions/runs/25102824494/job/73556728915?pr=6910

The error:

diff --git a/_build/default/tests/reftests/pin.test b/_build/default/tests/reftests/pin.out
File "tests/reftests/pin.test", line 1, characters 0-0:
index 581969b..baf3f8d 100644
/usr/bin/git --no-pager diff --no-index --color=always -u _build/default/tests/reftests/pin.test _build/default/tests/reftests/pin.out
--- a/_build/default/tests/reftests/pin.test
Command exited with code 1.
+++ b/_build/default/tests/reftests/pin.out
@@ -241,8 +241,8 @@ The following actions will be performed:
 -> installed nip-git2.ved
 Done.
 ### opam pin add ./nip-path2 --kind git | sed-cmd git | "128.*" -> "128"
-[ERROR] Command "git -C ${BASEDIR}/nip-path2 ls-files" failed:
-"git -C ${BASEDIR}/nip-path2 ls-files" exited with code 128
+[ERROR] Command "git -C /tmp/build_e05667_dune/opam-reftest-c7128
+"git -C /tmp/build_e05667_dune/opam-reftest-c7128
 # Return code 99 #
 ### : auto
 ### opam pin add ./nip-git3 --kind auto
make: *** [Makefile:217: tests] Error 1
Error: Process completed with exit code 2.

@NathanReb
Copy link
Copy Markdown
Collaborator Author

Ah just got it, the regexp matched on the generated directory name! I'll see if I can make the regexp more robust!

@NathanReb
Copy link
Copy Markdown
Collaborator Author

Maybe that should in fact be fixed at the reftest-runner level though, it seems the regexp was applied before the path normalization, I doubt there is any concrete case where we want that. Let me know what you'd prefer!

@NathanReb
Copy link
Copy Markdown
Collaborator Author

I went for the former. A bit of testing showed that the changes in the reftest runner would be a bit more involved than I anticipated as in some tests at least, sed-cmd as to be run before the common_filters so we'd need a finer orderding than simply common_filters @ filters.

@NathanReb NathanReb changed the title Remove use of chdir Remove unnecessary use of chdir Apr 29, 2026
@NathanReb NathanReb force-pushed the remove-chdir branch 2 times, most recently from 0d30ecc to bdd18eb Compare May 4, 2026 13:57
@NathanReb
Copy link
Copy Markdown
Collaborator Author

rebased on top of #6922 to show the impact on the opam pin list bug.

@NathanReb NathanReb force-pushed the remove-chdir branch 3 times, most recently from ff34cee to 2bd16e7 Compare May 5, 2026 12:59
@NathanReb
Copy link
Copy Markdown
Collaborator Author

Is anything still blocking this?

Comment thread src/client/opamConfigCommand.ml
Copy link
Copy Markdown
Collaborator

@rjbou rjbou left a comment

Choose a reason for hiding this comment

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

Tiny comments, otherwise, lgtm!

Comment thread src/repository/opamHTTP.ml Outdated
Comment thread master_changes.md Outdated
NathanReb added 3 commits May 13, 2026 18:56
Signed-off-by: Nathan Rebours <nathan.rebours@ocamlpro.com>
Signed-off-by: Nathan Rebours <nathan.rebours@ocamlpro.com>
With the new `git -C` commands showing, the regexp could
potentially match on the path passed to the `-C` option.

Signed-off-by: Nathan Rebours <nathan.rebours@ocamlpro.com>
@kit-ty-kate
Copy link
Copy Markdown
Member

Thanks!

@kit-ty-kate kit-ty-kate merged commit 9f9fc5d into ocaml:master May 13, 2026
40 checks passed
kit-ty-kate added a commit to ocaml-opam/opam-rt that referenced this pull request May 15, 2026
kit-ty-kate added a commit to kit-ty-kate/opam-publish that referenced this pull request May 15, 2026
rjbou pushed a commit to kit-ty-kate/opam-publish that referenced this pull request May 18, 2026
rjbou added a commit to ocaml-opam/opam-publish that referenced this pull request May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants