Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore oldcwd if process creation fails #5441

Merged
merged 2 commits into from
Feb 15, 2023
Merged

Conversation

dra27
Copy link
Member

@dra27 dra27 commented Feb 10, 2023

Spotted when package commands fail during switch creation - the cwd is left in the build directory for the package which on Windows then prevents the switch from being cleaned up.

@dra27 dra27 added this to the 2.2.0~alpha milestone Feb 10, 2023
@dra27 dra27 added this to PR in progress in Opam 2.2.0 via automation Feb 10, 2023
@dra27 dra27 moved this from PR in progress to PR to review for 2.2.0~alpha in Opam 2.2.0 Feb 10, 2023
Comment on lines 453 to 454
begin try Unix.chdir oldcwd
with Unix.Unix_error _ -> () end;
Copy link
Member

Choose a reason for hiding this comment

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

Looks obviously correct but couldn’t we merge both uses of Unix.chdir using Fun.protect starting below the first Unix.chdir at the top of the function? This way if another reraise or uncaught exception occures it will be handled automatically

Copy link
Member Author

@dra27 dra27 Feb 10, 2023

Choose a reason for hiding this comment

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

Yeah, I should have avoided being lazy (the laziness is having to add Fun.protect to OpamCompat )

@@ -618,3 +619,4 @@ users)
* `OpamStd.Option`: add `equal` function [#5374 @rjbou]
* `OpamStd.Compare`: add module to flag polymorphic comparison functions in opam codebase [#5374 @kit-ty-kate @rjbou]
* `OpamStd.Env.`: introduce OpamStd.Env.Name to abstract environment variable names [#5356 @dra27]
* `OpamCompat`: Add `Fun.protect` [#5441 @kit-ty-kate]
Copy link
Collaborator

Choose a reason for hiding this comment

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

❤️

Copy link
Member

Choose a reason for hiding this comment

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

Hum we already had OpamStd.Fun.finally which is the same function (way before there was a Fun module in the stdlib :/)
It'd be best to ensure we consistently use the same function everywhere.

@rjbou rjbou moved this from PR to review for 2.2.0~alpha to PR finalised (merge with CI) in Opam 2.2.0 Feb 15, 2023
@rjbou
Copy link
Collaborator

rjbou commented Feb 15, 2023

thanks!

@rjbou rjbou merged commit 7b14275 into ocaml:master Feb 15, 2023
Opam 2.2.0 automation moved this from PR finalised (merge with CI) to Done Feb 15, 2023
@rjbou rjbou mentioned this pull request Jun 15, 2023
16 tasks
@dra27 dra27 deleted the process-error-cwd branch April 8, 2024 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Opam 2.2.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants