opam
opam copied to clipboard
Creation of opam switch fails if the cwd get erased
I don't think it's a super important issue so don't hesitate to close if it makes it for easier operations.
But it seems that if you are in a directory, invoke opam switch create
to create a non-local switch and then somehow erase that directory you end up with:
[ERROR] Actions cancelled because of Sys_error("No such file or directory")
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] n
Fatal error:
Sys_error("No such file or directory")
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
Backtrace:
Raised at file "src/client/opamSwitchCommand.ml", line 348, characters 4-11
Called from file "src/client/opamCommands.ml", line 2126, characters 8-177
Called from file "src/state/opamGlobalState.ml", line 162, characters 14-18
Re-raised at file "src/core/opamStd.ml", line 1164, characters 4-38
Called from file "src_ext/cmdliner/src/cmdliner_term.ml", line 27, characters 19-24
Called from file "src_ext/cmdliner/src/cmdliner.ml", line 27, characters 27-34
Called from file "src_ext/cmdliner/src/cmdliner.ml", line 106, characters 32-39
Called from file "src_ext/cmdliner/src/cmdliner.ml", line 136, characters 18-36
Called from file "src_ext/cmdliner/src/cmdliner.ml", line 251, characters 22-48
Called from file "src/client/opamMain.ml", line 207, characters 6-64
Called from file "src/client/opamMain.ml", line 136, characters 6-10
Indeed, it's not the most usual case :)
I tried to reproduce (debian), but didn't succeed to fail:
-
- create dir
- opam sw create non local switch to the end
- remove dir from another terminal
-
opam list
on the two terms are ok
-
- create dir
- opam sw create non local switch with a long compiling time
- remove dir from another terminal, with the switch creation / ocaml compilation didn't end yet
- switch creation ends correctly
-
opam list
on the two terms are ok
Do you have another workflow?
Do you have another workflow?
"Workflow" is hyperbole :-) but it was 2. I can reproduce on macOS 10.15.7 with:
mkdir /tmp/bla
cd /tmp/bla
opam switch create 4.06.0
Now in another terminal rm -r /tmp/bla
.
[...]
[ERROR] Actions cancelled because of Sys_error("No such file or directory")
Ok! I don't have a macos available to test. If you have a moment, can you try to give the full log of the switch creation with a debug level to 3? It is quite long, maybe on a gist
@rjbou I can give you access to my test mac mini i got off of ebay a couple of months ago. Just send me your public key in DM if you'd want that
Sorry @rjbou I missed your message here you have: https://gist.github.com/dbuenzli/fb5435310654dee8ab0193e1d16122e3
Thanks @kit-ty-kate I'll keep this in mind for further mac-related experiments.
On the issue itself: at each process launch, opam retrieve the cwd (to rollback to the good dir), so when the directory is removed, the getcwd()
function call errors on mac (but not on deb).