Skip to content

Commit

Permalink
change binary search path, fix #32
Browse files Browse the repository at this point in the history
  • Loading branch information
phiresky committed Apr 8, 2020
1 parent da10b5c commit 9f11906
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/bin/rga.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down

0 comments on commit 9f11906

Please sign in to comment.