mirror of
https://github.com/phiresky/ripgrep-all.git
synced 2024-11-12 19:10:32 +00:00
change binary search path, fix #32
This commit is contained in:
parent
da10b5c1c9
commit
9f11906151
@ -116,9 +116,11 @@ fn add_exe_to_path() -> Fallible<()> {
|
||||
exe.pop(); // dirname
|
||||
|
||||
let path = env::var_os("PATH").unwrap_or("".into());
|
||||
let mut paths = env::split_paths(&path).collect::<Vec<_>>();
|
||||
paths.push(exe.to_owned()); // append: this way system PATH gets higher priority than bundled versions
|
||||
paths.push(exe.join("lib"));
|
||||
let paths = env::split_paths(&path).collect::<Vec<_>>();
|
||||
// prepend: prefer bundled versions to system-installed versions of binaries
|
||||
// solves https://github.com/phiresky/ripgrep-all/issues/32
|
||||
// may be somewhat of a security issue if rga binary is in installed in unprivileged locations
|
||||
let paths = [&[exe.to_owned(), exe.join("lib")], &paths[..]].concat();
|
||||
let new_path = env::join_paths(paths)?;
|
||||
env::set_var("PATH", &new_path);
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user