diff --git a/src/cli/shell_hook.rs b/src/cli/shell_hook.rs index 6e6879753..45947e8c8 100644 --- a/src/cli/shell_hook.rs +++ b/src/cli/shell_hook.rs @@ -8,7 +8,7 @@ use rattler_shell::{ shell::ShellEnum, }; -use crate::prefix::Prefix; +use crate::{prefix::Prefix, Project}; /// Print the activation script #[derive(Parser, Debug)] @@ -20,13 +20,20 @@ pub struct Args { /// Generates the activation script. fn generate_activation_script(shell: Option) -> miette::Result { + let project = Project::discover()?; + let platform = Platform::current(); + let env_dir = project.default_environment().dir(); let prefix = Prefix::new(PathBuf::new())?; let shell = shell.unwrap_or_default(); - let platform = Platform::current(); let activator = Activator::from_path(prefix.root(), shell, platform).into_diagnostic()?; - let path = std::env::var("PATH") + let mut path = std::env::var("PATH") .ok() .map(|p| std::env::split_paths(&p).collect::>()); + if let Some(path) = path.as_mut() { + path.push(env_dir); + } else { + path = Some(vec![env_dir]); + } // If we are in a conda environment, we need to deactivate it before activating the host / build prefix let conda_prefix = std::env::var("CONDA_PREFIX").ok().map(|p| p.into());