diff --git a/docs/configuration.md b/docs/configuration.md index f2a682f2f..d86336359 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -313,14 +313,20 @@ If the project is cross-compiled, the architecture of the build and target machi If you want to run an activation script inside the environment when either doing a `pixi run` or `pixi shell` these can be defined here. The scripts defined in this table will be sourced when the environment is activated using `pixi run` or `pixi shell` +!!! note + The activation scripts are run by the system shell interpreter as they run before an environment is available. + This means that it runs as `cmd.exe` on windows and `bash` on linux and osx (Unix). + Only `.sh`, `.bash` and `.bat` files are supported. + + If you have scripts per platform use the [target](#the-target-table) table. + ```toml [activation] scripts = ["env_setup.sh"] +# To support windows platforms as well add the following +[target.win-64.activation] +scripts = ["env_setup.bat"] ``` -!!! note - Specify different scripts for different platforms using the [target](#the-target-table) table - - ## The `target` table The target table is a table that allows for platform specific configuration. diff --git a/src/cli/run.rs b/src/cli/run.rs index e89f42216..4a7c9cc5a 100644 --- a/src/cli/run.rs +++ b/src/cli/run.rs @@ -306,7 +306,19 @@ pub async fn run_activation_async( project: &Project, prefix: Prefix, ) -> miette::Result> { - let additional_activation_scripts = project.activation_scripts(Platform::current())?; + let platform = Platform::current(); + let additional_activation_scripts = project.activation_scripts(platform)?; + + // Check if the platform and activation script extension match. For Platform::Windows the extension should be .bat and for All other platforms it should be .sh or .bash. + for script in additional_activation_scripts.iter() { + let extension = script.extension().unwrap_or_default(); + if platform.is_windows() && extension != "bat" { + tracing::warn!("The activation script '{}' does not have the correct extension for the platform '{}'. The extension should be '.bat'.", script.display(), platform); + } else if !platform.is_windows() && extension != "sh" && extension != "bash" { + tracing::warn!("The activation script '{}' does not have the correct extension for the platform '{}'. The extension should be '.sh' or '.bash'.", script.display(), platform); + } + } + await_in_progress( "activating environment", run_activation(prefix, additional_activation_scripts.into_iter().collect()),