From 0d3f76ddefedd46229be200d8080f1520bb89b0f Mon Sep 17 00:00:00 2001 From: Douglas <32344964+NotTheDr01ds@users.noreply.github.com> Date: Thu, 2 Jan 2025 13:05:02 -0500 Subject: [PATCH] Remove no-longer-needed convert_env_values calls (#14681) # Description Takes advantage of #14591 to remove the now-necessary calls to `convert_env_values()` that I added in #14249. The function is now just called once to convert `PATH`. Also removed the Windows-build-time checks for `ensure_path`, since previous case-insensitivity fixes make this unnecessary as well. # User-Facing Changes None - #14591 now handles conversion 'on-demand'. # Tests + Formatting - :green_circle: `toolkit fmt` - :green_circle: `toolkit clippy` - :green_circle: `toolkit test` - :green_circle: `toolkit test stdlib` # After Submitting N/A --- crates/nu-cli/src/repl.rs | 9 +-------- crates/nu-engine/src/env.rs | 17 +---------------- src/config_files.rs | 12 ------------ 3 files changed, 2 insertions(+), 36 deletions(-) diff --git a/crates/nu-cli/src/repl.rs b/crates/nu-cli/src/repl.rs index 19f4aba22f..965066d2e4 100644 --- a/crates/nu-cli/src/repl.rs +++ b/crates/nu-cli/src/repl.rs @@ -19,7 +19,7 @@ use miette::{ErrReport, IntoDiagnostic, Result}; use nu_cmd_base::util::get_editor; use nu_color_config::StyleComputer; #[allow(deprecated)] -use nu_engine::{convert_env_values, current_dir_str, env_to_strings}; +use nu_engine::{current_dir_str, env_to_strings}; use nu_parser::{lex, parse, trim_quotes_str}; use nu_protocol::{ config::NuCursorShape, @@ -81,13 +81,6 @@ pub fn evaluate_repl( stack.clone(), ); - let start_time = std::time::Instant::now(); - // Translate environment variables from Strings to Values - if let Err(e) = convert_env_values(engine_state, &unique_stack) { - report_shell_error(engine_state, &e); - } - perf!("translate env vars", start_time, use_color); - // seed env vars unique_stack.add_env_var( "CMD_DURATION_MS".into(), diff --git a/crates/nu-engine/src/env.rs b/crates/nu-engine/src/env.rs index 54f800958f..0d3fde7de6 100644 --- a/crates/nu-engine/src/env.rs +++ b/crates/nu-engine/src/env.rs @@ -89,22 +89,7 @@ pub fn convert_env_values(engine_state: &mut EngineState, stack: &Stack) -> Resu } } - #[cfg(not(windows))] - { - error = error.or_else(|| ensure_path(&mut new_scope, "PATH")); - } - - #[cfg(windows)] - { - let first_result = ensure_path(&mut new_scope, "Path"); - if first_result.is_some() { - let second_result = ensure_path(&mut new_scope, "PATH"); - - if second_result.is_some() { - error = error.or(first_result); - } - } - } + error = error.or_else(|| ensure_path(&mut new_scope, "PATH")); if let Ok(last_overlay_name) = &stack.last_overlay_name() { if let Some(env_vars) = Arc::make_mut(&mut engine_state.env_vars).get_mut(last_overlay_name) diff --git a/src/config_files.rs b/src/config_files.rs index 6a612ea4a7..56769cf330 100644 --- a/src/config_files.rs +++ b/src/config_files.rs @@ -51,18 +51,6 @@ pub(crate) fn read_config_file( use_color ); } else { - let start_time = std::time::Instant::now(); - let config = engine_state.get_config(); - let use_color = config.use_ansi_coloring.get(engine_state); - if let Err(e) = convert_env_values(engine_state, stack) { - report_shell_error(engine_state, &e); - } - perf!( - "translate env vars before default_config.nu", - start_time, - use_color - ); - eval_default_config(engine_state, stack, get_default_config(), is_env_config); };