Remove std::env::set_current_dir() call from EngineState::merge_env() (#12922)

As discussed in https://github.com/nushell/nushell/pull/12749, we no
longer need to call `std::env::set_current_dir()` to sync `$env.PWD`
with the actual working directory. This PR removes the call from
`EngineState::merge_env()`.
This commit is contained in:
YizhePKU
2024-05-23 00:58:27 +08:00
committed by GitHub
parent 75689ec98a
commit 7ede90cba5
10 changed files with 41 additions and 83 deletions

View File

@ -277,11 +277,7 @@ impl EngineState {
}
/// Merge the environment from the runtime Stack into the engine state
pub fn merge_env(
&mut self,
stack: &mut Stack,
cwd: impl AsRef<Path>,
) -> Result<(), ShellError> {
pub fn merge_env(&mut self, stack: &mut Stack) -> Result<(), ShellError> {
let mut config_updated = false;
for mut scope in stack.env_vars.drain(..) {
@ -311,9 +307,6 @@ impl EngineState {
}
}
// TODO: better error
std::env::set_current_dir(cwd)?;
if config_updated {
// Make plugin GC config changes take effect immediately.
#[cfg(feature = "plugin")]