mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 03:17:58 +02:00
Don't insert PATH variable on Windows (#3422)
* Don't insert PATH variable on Windows * Simplify fix * Just centralize the var * Add a message about why we have to workaround the issue
This commit is contained in:
@ -9,6 +9,11 @@ pub struct Outcome {
|
||||
pub err: String,
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
pub const NATIVE_PATH_ENV_VAR: &str = "Path";
|
||||
#[cfg(not(windows))]
|
||||
pub const NATIVE_PATH_ENV_VAR: &str = "PATH";
|
||||
|
||||
impl Outcome {
|
||||
pub fn new(out: String, err: String) -> Outcome {
|
||||
Outcome { out, err }
|
||||
@ -29,7 +34,7 @@ pub fn pipeline(commands: &str) -> String {
|
||||
pub fn shell_os_paths() -> Vec<std::path::PathBuf> {
|
||||
let mut original_paths = vec![];
|
||||
|
||||
if let Some(paths) = std::env::var_os("PATH") {
|
||||
if let Some(paths) = std::env::var_os(NATIVE_PATH_ENV_VAR) {
|
||||
original_paths = std::env::split_paths(&paths).collect::<Vec<_>>();
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ macro_rules! nu {
|
||||
pub use std::error::Error;
|
||||
pub use std::io::prelude::*;
|
||||
pub use std::process::{Command, Stdio};
|
||||
pub use $crate::NATIVE_PATH_ENV_VAR;
|
||||
|
||||
let commands = &*format!(
|
||||
"
|
||||
@ -46,7 +47,7 @@ macro_rules! nu {
|
||||
};
|
||||
|
||||
let mut process = match Command::new($crate::fs::executable_path())
|
||||
.env("PATH", paths_joined)
|
||||
.env(NATIVE_PATH_ENV_VAR, paths_joined)
|
||||
.arg("--skip-plugins")
|
||||
.arg("--no-history")
|
||||
.arg("--config-file")
|
||||
@ -98,6 +99,7 @@ macro_rules! nu_with_plugins {
|
||||
pub use std::error::Error;
|
||||
pub use std::io::prelude::*;
|
||||
pub use std::process::{Command, Stdio};
|
||||
pub use crate::NATIVE_PATH_ENV_VAR;
|
||||
|
||||
let commands = &*format!(
|
||||
"
|
||||
@ -126,7 +128,7 @@ macro_rules! nu_with_plugins {
|
||||
};
|
||||
|
||||
let mut process = match Command::new($crate::fs::executable_path())
|
||||
.env("PATH", paths_joined)
|
||||
.env(NATIVE_PATH_ENV_VAR, paths_joined)
|
||||
.stdout(Stdio::piped())
|
||||
.stdin(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
|
@ -99,7 +99,7 @@ impl NuProcess {
|
||||
Err(_) => panic!("Couldn't join paths for PATH var."),
|
||||
};
|
||||
|
||||
command.env("PATH", paths_joined);
|
||||
command.env(crate::NATIVE_PATH_ENV_VAR, paths_joined);
|
||||
|
||||
for env_var in &self.environment_vars {
|
||||
command.env(&env_var.name, &env_var.value);
|
||||
|
Reference in New Issue
Block a user