You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Something I noticed while writing #105, but I opted to leave things as they are:
When expanding a ~, if home_dir (or env_home_dir) returns None (eg: $HOME is unset, or on a platform like WASM where there is no home directory), then tilde_expansion() turns it into an empty PathBuf by unwrap_or_default():
"found tilde, substituting in user's home directory to get {}",
new_path.display()
);
Cow::Owned(new_path)
That would cause which to search a path relative to the current working directory for binaries, rather than the intended path.
This should probably return some error instead (or skip searching paths containing ~ if there is no home directory), but I think that could be a significant behaviour change on some platforms / environments.
The text was updated successfully, but these errors were encountered:
Xaeroxe
added a commit
to Xaeroxe/which-rs
that referenced
this issue
Dec 19, 2024
Something I noticed while writing #105, but I opted to leave things as they are:
When expanding a
~
, ifhome_dir
(orenv_home_dir
) returnsNone
(eg:$HOME
is unset, or on a platform like WASM where there is no home directory), thentilde_expansion()
turns it into an emptyPathBuf
byunwrap_or_default()
:which-rs/src/finder.rs
Lines 268 to 276 in 1b5f7be
That would cause
which
to search a path relative to the current working directory for binaries, rather than the intended path.This should probably return some error instead (or skip searching paths containing
~
if there is no home directory), but I think that could be a significant behaviour change on some platforms / environments.The text was updated successfully, but these errors were encountered: