Panic when using `--full-path` if current working directory is invalid or removed
Description
When --full-path (or -f) is used, fd builds absolute paths for each match. If the process’s current working directory becomes invalid during the search (e.g. it was deleted or permissions changed), the program can panic instead of reporting an error.
Location: src/walk.rs, in the worker closure that builds search_str for full-path matching (around lines 521–524).
Cause: filesystem::path_absolute_form(entry_path) can return an Err (for example when env::current_dir() fails). The code uses .expect("Retrieving absolute path succeeds"), which turns that error into a panic.
Reproduction (conceptually):
- Start fd with
--full-pathin a directory. - From another process/shell, remove or make the current directory inaccessible (e.g.
rmdirthe CWD or revoke access) while the search is running. - When fd tries to resolve a relative path,
path_absolute_formfails and the process panics.
Suggested fix: Do not use .expect(). Either propagate the error (e.g. with ?) so the search can fail gracefully, or send a WorkerResult::Error and continue, so the user gets an error message and a non-zero exit code instead of a panic.
Hi, @tmccombs are you able to check this issue? If needed, I'd love to work on this. thx
Taking a look at this. @dataCenter430, if you're already working on a fix, let me know and I'll step back.