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

helix panics if started in non-existent dir #8068

Open
sigmaSd opened this issue Aug 26, 2023 · 4 comments
Open

helix panics if started in non-existent dir #8068

sigmaSd opened this issue Aug 26, 2023 · 4 comments
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug

Comments

@sigmaSd
Copy link
Contributor

sigmaSd commented Aug 26, 2023

Summary

helix panics if cwd is removed

Reproduction Steps

  • mkdir a
  • cd a
  • from another terminal rm -rf a
  • hx

expected: no crash
actual: panics

thread 'main' panicked at 'Couldn't determine current working directory: Os { code: 2, kind: NotFound, message: "No such file or directory" }', helix-loader/src/lib.rs:29:10

#7185 says this is an internal invariant but in reality its used in many places accessible from the outside

Helix log

No response

Platform

linux

Terminal Emulator

weterm

Helix Version

helix 23.05 (c9694f6)

@sigmaSd sigmaSd added the C-bug Category: This is a bug label Aug 26, 2023
@the-mikedavis the-mikedavis changed the title helix panics if cwd is removed helix panics if started in non-existent dir Aug 26, 2023
@pascalkuthe
Copy link
Member

I just don't see how this would work. If the cwd doesn't exists before helix is started then it's impossible for us ti the determine the cwd oath so all commands that use the cwd (:open, anytime you start an LSP, file picker, global search,...) just won't work properly. I think its entirely reasonable to assume that the cwd exists at startup.

Especially because helix crashes immidietly (so no lost work) with an entirely reasonable error message I just don't think it's worth the extra headache to fix.

@cronhan
Copy link

cronhan commented Aug 29, 2023

I also recently experienced it, and even though I understood the message, it was not apparent what was wrong immediately since the shell did not give a similar error message (and my prompt includes the full CWD so even more "confusing"). So I think it might be good to at least adjust the error message to also include the path that it tried but does not exist? Or add a hint to the message that the user should check whether that directory exists/was removed by another process?

@kirawi kirawi added the A-helix-term Area: Helix term improvements label Sep 9, 2023
@eminence
Copy link

I think the only other possible option is for helix to change to a different directory, when the cwd doesn't exist. But then you're left with the question of what directory should that be, and then the subsequent possible confusion from users when that happens. So the current behavior of refusing to start seems well justified.

I think probably a lot of people have come to associate panic error messages with bugs, rightly or wrongly.

Would you accept a PR that improves this message a bit? Something like:

Error: Couldn't determine current working directory.  Check that '/tmp/a` exists.

@pascalkuthe
Copy link
Member

Yeah I think helix should just print an error message and exit with an error code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

5 participants