SHA256
Trying using absolute paths now for binaries executions.
This commit is contained in:
+12
-7
@@ -101,7 +101,9 @@ impl std::error::Error for ExecCommandError {}
|
||||
|
||||
/// exec given command with arguments, capturing stderr in case or failure
|
||||
pub fn exec_command(cmd: &str, args: &Vec<&str>) -> Result<(), ExecCommandError> {
|
||||
let out = Command::new(cmd).args(args).output()?;
|
||||
// For testing shake lets assume all binaries is in /usr/bin
|
||||
let ex_cmd = format!("/usr/bin/{}", cmd);
|
||||
let out = Command::new(ex_cmd).args(args).output()?;
|
||||
if out.status.success() {
|
||||
Ok(())
|
||||
} else {
|
||||
@@ -236,13 +238,16 @@ pub fn set_env_vars_unsafe() -> () {
|
||||
let custom_lib = "/usr/lib";
|
||||
|
||||
// 2. Retrieve existing paths to append/prepend (optional but recommended)
|
||||
let existing_path = env::var("PATH").unwrap_or_else(|_| String::new());
|
||||
let existing_ld_path = env::var("LD_LIBRARY_PATH").unwrap_or_else(|_| String::new());
|
||||
|
||||
// 3. Construct new path strings
|
||||
// Prepend custom paths so they take precedence
|
||||
let new_path = format!("{}:{}", custom_bin, existing_path);
|
||||
let new_ld_path = format!("{}:{}", custom_lib, existing_ld_path);
|
||||
let new_path = match env::var("PATH") {
|
||||
Err(_) => custom_bin.to_string(),
|
||||
Ok(v) => format!("{}:{}", v, custom_bin)
|
||||
};
|
||||
|
||||
let new_ld_path = match env::var("LD_LIBRARY_PATH") {
|
||||
Err(_) => custom_lib.to_string(),
|
||||
Ok(v) => format!("{}:{}", v, custom_lib)
|
||||
};
|
||||
|
||||
// 4. Set environment variables (UNSAFE in Rust 2024+)
|
||||
// MUST be done before spawning any threads or async runtimes
|
||||
|
||||
Reference in New Issue
Block a user