Revert "Remove std::env::set_current_dir() call from EngineState::merge_env()" (#12954)

Reverts nushell/nushell#12922
This commit is contained in:
Darren Schroeder
2024-05-24 11:09:59 -05:00
committed by GitHub
parent bf07806b1b
commit 7d11c28eea
10 changed files with 83 additions and 41 deletions

View File

@ -277,7 +277,11 @@ impl EngineState {
}
/// Merge the environment from the runtime Stack into the engine state
pub fn merge_env(&mut self, stack: &mut Stack) -> Result<(), ShellError> {
pub fn merge_env(
&mut self,
stack: &mut Stack,
cwd: impl AsRef<Path>,
) -> Result<(), ShellError> {
let mut config_updated = false;
for mut scope in stack.env_vars.drain(..) {
@ -307,6 +311,9 @@ 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")]