mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 08:06:03 +02:00
when spawned process during register plugin, pass env to child process (#6261)
* when spawned process during register plugin, pass env to child process * tweak comment * tweak comment * remove trailing whitespace Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
This commit is contained in:
@ -61,6 +61,10 @@ impl Command for PluginDeclaration {
|
||||
// Create PipelineData
|
||||
let source_file = Path::new(&self.filename);
|
||||
let mut plugin_cmd = create_command(source_file, &self.shell);
|
||||
// We need the current environment variables for `python` based plugins
|
||||
// Or we'll likely have a problem when a plugin is implemented in a virtual Python environment.
|
||||
let current_envs = nu_engine::env::env_to_strings(engine_state, stack).unwrap_or_default();
|
||||
plugin_cmd.envs(current_envs);
|
||||
|
||||
let mut child = plugin_cmd.spawn().map_err(|err| {
|
||||
let decl = engine_state.get_decl(call.decl_id);
|
||||
|
@ -1,6 +1,7 @@
|
||||
mod declaration;
|
||||
pub use declaration::PluginDeclaration;
|
||||
use nu_engine::documentation::get_flags_section;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::protocol::{CallInput, LabeledError, PluginCall, PluginData, PluginResponse};
|
||||
use crate::EncodingType;
|
||||
@ -117,9 +118,11 @@ pub fn get_signature(
|
||||
path: &Path,
|
||||
encoding: &EncodingType,
|
||||
shell: &Option<PathBuf>,
|
||||
current_envs: &HashMap<String, String>,
|
||||
) -> Result<Vec<Signature>, ShellError> {
|
||||
let mut plugin_cmd = create_command(path, shell);
|
||||
|
||||
plugin_cmd.envs(current_envs);
|
||||
let mut child = plugin_cmd.spawn().map_err(|err| {
|
||||
ShellError::PluginFailedToLoad(format!("Error spawning child process: {}", err))
|
||||
})?;
|
||||
|
Reference in New Issue
Block a user