-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
doesn't work in a nonexistent dir #1291
Comments
Could you please describe the use case for running ripgrep in a directory that doesn't exist? |
I just cd'ed into some temporary directory, created by my tests runner application (running somewhere in the background). And then I was doing some debugging. |
I may agree to some extent that this case is not very typical, and probably one should watch the directory they work in, and do not execute commands in some their random terminal session :) |
I encountered this bug because I was in a network mounted directory but the network connection (OneDrive via rclone in this case) had been closed. It did cause quite a bit of confusion until a colleague suggested I check the working directory. This had not occurred to me because I was searching a completely different part of the file system. |
I encountered this because I was sitting in |
It turns out that querying the CWD while in a directory that no longer exists results in an error. Since the CWD is queried every time ripgrep starts---whether it needs it or not---for dealing with glob matching, ripgrep winds up being completely useless inside a non-existent directory. We fix this in a few different ways: * Firstly, if std::env::current_dir() fails, then we fall back to trying to read the `PWD` environment variable. * If that fails, that we return a more sensible error message so that a user can at least react to the problem. Previously, the error message was inscrutable. * Finally, we try to avoid the problem altogether by building empty glob matchers if not globs were provided, thus side-stepping querying the CWD completely. Fixes #1291, Closes #1400
What version of ripgrep are you using?
How did you install ripgrep?
cargo install ripgrep
What operating system are you using ripgrep on?
Ubuntu 19.04
Describe your question, feature request, or bug.
When the CWD is a nonexistent directory, and ripgrep is invoked, it always fails even if target is a valid absolute path. GNU grep works in this case.
If this is a bug, what are the steps to reproduce the behavior?
According to strace, ripgrep invokes getcwd() at some point and fails with it.
If this is a bug, what is the actual behavior?
If this is a bug, what is the expected behavior?
I expect ripgrep to fail only in cases when any relative paths are used, while the only-absolute-paths command should be successfully executed.
The text was updated successfully, but these errors were encountered: