Skip to content
New issue

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

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

Already on GitHub? # to your account

Creation of opam switch fails if the cwd get erased #4455

Open
dbuenzli opened this issue Nov 28, 2020 · 6 comments · May be fixed by #5966
Open

Creation of opam switch fails if the cwd get erased #4455

dbuenzli opened this issue Nov 28, 2020 · 6 comments · May be fixed by #5966

Comments

@dbuenzli
Copy link
Contributor

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
@rjbou
Copy link
Collaborator

rjbou commented Dec 1, 2020

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?

@dbuenzli
Copy link
Contributor Author

dbuenzli commented Dec 2, 2020

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")

@rjbou
Copy link
Collaborator

rjbou commented Dec 15, 2020

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

@kit-ty-kate
Copy link
Member

@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

@dbuenzli
Copy link
Contributor Author

Sorry @rjbou I missed your message here you have: https://gist.github.com/dbuenzli/fb5435310654dee8ab0193e1d16122e3

@rjbou
Copy link
Collaborator

rjbou commented Jan 6, 2021

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).

@dra27 dra27 added this to the 2.2.0~alpha milestone Jan 22, 2021
@dra27 dra27 removed this from the 2.2.0~alpha milestone May 17, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants