Skip to main content

jnc exec

Runs a command in a temporary, isolated environment. The required packages are automatically installed into a cached environment and the command is executed within it. This is useful for one-off commands without creating a full workspace. Temporary environments are cached for reuse. Clear them with jnc clean cache --exec.

Usage

jnc exec [OPTIONS] <COMMAND> [ARGS]...
Alias: x

Arguments

ArgumentDescription
<COMMAND> [ARGS]...The executable to run, followed by any arguments. If --spec is not provided, the package is guessed from the command name.

Options

OptionShortDescription
--spec <SPEC>-sMatchspecs of packages to install. Can be specified multiple times. When provided, disables automatic package guessing.
--with <SPEC>-wAdditional matchspecs to install alongside the guessed package. Cannot be combined with --spec.
--channel <CHANNEL>-cThe channel to search for packages. Can be specified multiple times. Defaults to conda-forge.
--platform <PLATFORM>-pThe platform to create the environment for. Defaults to the current platform.
--force-reinstallAlways create a new environment, even if a cached one exists.
--list[=REGEX]List packages in the environment before executing the command. Optionally filter by regex.
--no-modify-ps1Disable modification of the PS1 prompt to indicate the temporary environment.

Examples

Run Python in a temporary environment:
jnc exec python
Run Python with a specific version:
jnc exec --spec "python=3.12" python -- -c "print('hello')"
Run a command with additional packages:
jnc exec --with numpy python -- -c "import numpy; print(numpy.__version__)"
Use a specific channel:
jnc exec --channel conda-forge --spec "nodejs=20" node -- --version
Force a fresh environment:
jnc exec --force-reinstall python
List packages in the temporary environment before running:
jnc exec --list python