Use activation mode#
By default, conda-exec only prepends the environment’s bin/ directory to
PATH. The --activate flag applies full conda activation instead.
What –activate does#
With --activate, conda-exec runs conda’s activation logic before executing
the tool. This:
Sets
CONDA_PREFIXto the ephemeral environment pathExports environment variables defined by activation scripts (e.g.
JAVA_HOME,R_HOME)Unsets variables that activation marks for removal
Applies any
activate.d/scripts bundled with installed packages
Without --activate, only PATH is modified.
When you need activation#
Some tools check CONDA_PREFIX or rely on environment variables that
conda packages set through activation scripts. Common cases:
R packages that need
R_HOMEJava tools that need
JAVA_HOMEBioinformatics pipelines that check
CONDA_PREFIXto locate data filesTools that use
CONDA_DEFAULT_ENVfor configuration
conda exec --activate -c bioconda snakemake --cores 4
When you do not need activation#
Tip
Most CLI tools work without activation. If you are running linters,
formatters, or similar standalone tools, skip --activate for faster
execution.
Most standalone CLI tools only need the binary on PATH and work fine
without activation. For example, linters, formatters, and build tools
typically do not inspect CONDA_PREFIX:
conda exec ruff check .
conda exec black --check .
conda exec jq '.name' package.json
Skipping activation is the default because it is faster.
Performance#
Activation adds overhead to each invocation. It imports conda’s activation
machinery and processes activation scripts from installed packages. For
tools that do not need it, omitting --activate avoids this cost.
Example with a script#
Activation also works in script mode:
conda exec --activate script.py
The script runs inside a fully activated environment with CONDA_PREFIX
set, which is useful for scripts that call conda-aware libraries.