Magic commands
This document contains the help content for the magic
command-line program.
magic
magic - A high level package management tool by Modular for developing with Mojo and MAX.
To get started, run magic init
in your project directory.
To see all available commands, run magic --help
or magic help
.
Usage: magic [OPTIONS] <COMMAND>
Subcommands:
init
— Creates a new projectadd
— Adds dependencies to the projectremove
— Removes dependencies from the projectinstall
— Install all dependenciesupdate
— Update dependencies as recorded in the local lock filerun
— Runs task in projectshell
— Start a shell in the magic environment of the projectshell-hook
— Print the magic environment activation scriptproject
— Modify the project configuration file through the command linetask
— Interact with tasks in the projectlist
— List project's packagestree
— Show a tree of project dependenciesglobal
— Subcommand for global package management actionsconfig
— Configuration managementinfo
— Information about the system, project and environments for the current machinesearch
— Search a conda packageself-update
— Update magic to the latest or a specific versionclean
— Clean the parts of your system which are touched by magic. Defaults to cleaning the environments and task cache. Use thecache
subcommand to clean the cachecompletion
— Generates a completion script for a shelltelemetry
— Configure how telemetry data is emitted from magic and Modular packages
Options:
-
-v
,--verbose
— Increase logging verbosity -
-q
,--quiet
— Decrease logging verbosity -
--color <COLOR>
— Whether the log needs to be coloredDefault value:
auto
Possible values:
always
,never
,auto
-
--no-progress
— Hide all progress barsDefault value:
false
magic init
Creates a new project
Usage: magic init [OPTIONS] [PATH]
Arguments:
-
<PATH>
— Where to place the project (defaults to current path)Default value:
.
Options:
-
-c
,--channel <channel>
— Channels to use in the project -
-p
,--platform <platform>
— Platforms that the project supports -
-i
,--import <ENV_FILE>
— Environment.yml file to bootstrap the project -
--format <FORMAT>
— The manifest format to createPossible values:
magic
,pyproject
,mojoproject
magic add
Adds dependencies to the project
The dependencies should be defined as MatchSpec for conda package, or a PyPI requirement for the --pypi dependencies. If no specific version is provided, the latest version compatible with your project will be chosen automatically or a * will be used.
Example usage:
magic add python=3.9
: This will select the latest minor version that complies with 3.9.*, i.e., python version 3.9.0, 3.9.1, 3.9.2, etc.magic add python
: In absence of a specified version, the latest version will be chosen. For instance, this could resolve to python version 3.11.3.* at the time of writing.
Adding multiple dependencies at once is also supported:
magic add python pytest
: This will add bothpython
andpytest
to the project's dependencies.
The --platform
and --build/--host
flags make the dependency target
specific.
magic add python --platform linux-64 --platform osx-arm64
: Will add the latest version of python for linux-64 and osx-arm64 platforms.magic add python --build
: Will add the latest version of python for as a build dependency.
Mixing --platform
and --build
/--host
flags is supported
The --pypi
option will add the package as a pypi dependency. This can not
be mixed with the conda dependencies
magic add --pypi boto3
- `magic add --pypi "boto3==version"
If the project manifest is a pyproject.toml
, adding a pypi dependency will
add it to the native pyproject project.dependencies
array or to the native
project.optional-dependencies
table if a feature is specified:
magic add --pypi boto3
will addboto3
to theproject.dependencies
arraymagic add --pypi boto3 --feature aws
will addboto3
to theproject.dependencies.aws
array
These dependencies will then be read by magic as if they had been added to
the magic pypi-dependencies
tables of the default or of a named feature.
Usage: magic add [OPTIONS] <SPECS>...
Arguments:
<SPECS>
— The dependencies as names, conda MatchSpecs or PyPi requirements
Options:
-
--manifest-path <MANIFEST_PATH>
— The path to 'pixi.toml' or 'pyproject.toml' -
--host
— The specified dependencies are host dependencies. Conflicts withbuild
andpypi
-
--build
— The specified dependencies are build dependencies. Conflicts withhost
andpypi
-
--pypi
— The specified dependencies are pypi dependencies. Conflicts withhost
andbuild
-
-p
,--platform <PLATFORM>
— The platform(s) for which the dependency should be modified -
-f
,--feature <FEATURE>
— The feature for which the dependency should be modified -
--no-lockfile-update
— Don't update lockfile, implies the no-install as well -
--no-install
— Don't modify the environment, only modify the lock-file -
--tls-no-verify
— Do not verify the TLS certificate of the server -
--auth-file <AUTH_FILE>
— Path to the file containing the authentication token -
--pypi-keyring-provider <PYPI_KEYRING_PROVIDER>
— Specifies if we want to use uv keyring providerPossible values:
disabled
,subprocess
-
--editable
— Whether the pypi requirement should be editable
magic remove
Removes dependencies from the project
If the project manifest is a pyproject.toml
, removing a pypi dependency with the --pypi
flag will remove it from either - the native pyproject project.dependencies
array or, if a feature is specified, the native project.optional-dependencies
table - magic pypi-dependencies
tables of the default feature or, if a feature is specified, a named feature
Usage: magic remove [OPTIONS] <SPECS>...
Arguments:
<SPECS>
— The dependencies as names, conda MatchSpecs or PyPi requirements
Options:
-
--manifest-path <MANIFEST_PATH>
— The path to 'pixi.toml' or 'pyproject.toml' -
--host
— The specified dependencies are host dependencies. Conflicts withbuild
andpypi
-
--build
— The specified dependencies are build dependencies. Conflicts withhost
andpypi
-
--pypi
— The specified dependencies are pypi dependencies. Conflicts withhost
andbuild
-
-p
,--platform <PLATFORM>
— The platform(s) for which the dependency should be modified -
-f
,--feature <FEATURE>
— The feature for which the dependency should be modified -
--no-lockfile-update
— Don't update lockfile, implies the no-install as well -
--no-install
— Don't modify the environment, only modify the lock-file -
--tls-no-verify
— Do not verify the TLS certificate of the server -
--auth-file <AUTH_FILE>
— Path to the file containing the authentication token -
--pypi-keyring-provider <PYPI_KEYRING_PROVIDER>
— Specifies if we want to use uv keyring providerPossible values:
disabled
,subprocess
magic install
Install all dependencies
Usage: magic install [OPTIONS]
Options:
-
--manifest-path <MANIFEST_PATH>
— The path to 'pixi.toml' or 'pyproject.toml' -
--frozen
— Install the environment as defined in the lockfile, doesn't update lockfile if it isn't up-to-date with the manifest file -
--locked
— Check if lockfile is up-to-date before installing the environment, aborts when lockfile isn't up-to-date with the manifest file -
-e
,--environment <ENVIRONMENT>
— The environment to install -
--tls-no-verify
— Do not verify the TLS certificate of the server -
--auth-file <AUTH_FILE>
— Path to the file containing the authentication token -
--pypi-keyring-provider <PYPI_KEYRING_PROVIDER>
— Specifies if we want to use uv keyring providerPossible values:
disabled
,subprocess
-
-a
,--all
magic update
Update dependencies as recorded in the local lock file
Usage: magic update [OPTIONS] [PACKAGES]...
Arguments:
<PACKAGES>
— The packages to update
Options:
-
--tls-no-verify
— Do not verify the TLS certificate of the server -
--auth-file <AUTH_FILE>
— Path to the file containing the authentication token -
--pypi-keyring-provider <PYPI_KEYRING_PROVIDER>
— Specifies if we want to use uv keyring providerPossible values:
disabled
,subprocess
-
--manifest-path <MANIFEST_PATH>
— The path to 'pixi.toml' or 'pyproject.toml' -
--no-install
— Don't install the (solve) environments needed for pypi-dependencies solving -
-n
,--dry-run
— Don't actually write the lockfile or update any environment -
-e
,--environment <ENVIRONMENTS>
— The environments to update. If none is specified, all environments are updated -
-p
,--platform <PLATFORMS>
— The platforms to update. If none is specified, all platforms are updated -
--json
magic run
Runs task in project
Usage: magic run [OPTIONS] <TASK>...
Arguments:
<TASK>
— The magic task or a task shell command you want to run in the project's environment, which can be an executable in the environment's PATH
Options:
-
--manifest-path <MANIFEST_PATH>
— The path to 'pixi.toml' or 'pyproject.toml' -
--frozen
— Install the environment as defined in the lockfile, doesn't update lockfile if it isn't up-to-date with the manifest file -
--locked
— Check if lockfile is up-to-date before installing the environment, aborts when lockfile isn't up-to-date with the manifest file -
-e
,--environment <ENVIRONMENT>
— The environment to run the task in -
--tls-no-verify
— Do not verify the TLS certificate of the server -
--auth-file <AUTH_FILE>
— Path to the file containing the authentication token -
--pypi-keyring-provider <PYPI_KEYRING_PROVIDER>
— Specifies if we want to use uv keyring providerPossible values:
disabled
,subprocess
-
--clean-env
— Use a clean environment to run the taskUsing this flag will ignore your current shell environment and use bare minimum environment to activate the magic environment in.
magic shell
Start a shell in the magic environment of the project
Usage: magic shell [OPTIONS]
Options:
-
--manifest-path <MANIFEST_PATH>
— The path to 'pixi.toml' or 'pyproject.toml' -
--frozen
— Install the environment as defined in the lockfile, doesn't update lockfile if it isn't up-to-date with the manifest file -
--locked
— Check if lockfile is up-to-date before installing the environment, aborts when lockfile isn't up-to-date with the manifest file -
-e
,--environment <ENVIRONMENT>
— The environment to activate in the shell -
--tls-no-verify
— Do not verify the TLS certificate of the server -
--auth-file <AUTH_FILE>
— Path to the file containing the authentication token -
--pypi-keyring-provider <PYPI_KEYRING_PROVIDER>
— Specifies if we want to use uv keyring providerPossible values:
disabled
,subprocess
-
--change-ps1 <CHANGE_PS1>
— Do not change the PS1 variable when starting a promptPossible values:
true
,false
magic shell-hook
Print the magic environment activation script.
You can source the script to activate the environment without needing magic itself.
Usage: magic shell-hook [OPTIONS]
Options:
-
-s
,--shell <SHELL>
— Sets the shell, options: [bash
,zsh
,xonsh
,cmd
,powershell
,fish
,nushell
] -
--manifest-path <MANIFEST_PATH>
— The path to 'pixi.toml' or 'pyproject.toml' -
--frozen
— Install the environment as defined in the lockfile, doesn't update lockfile if it isn't up-to-date with the manifest file -
--locked
— Check if lockfile is up-to-date before installing the environment, aborts when lockfile isn't up-to-date with the manifest file -
-e
,--environment <ENVIRONMENT>
— The environment to activate in the script -
--json
— Emit the environment variables set by running the activation as JSONDefault value:
false
-
--tls-no-verify
— Do not verify the TLS certificate of the server -
--auth-file <AUTH_FILE>
— Path to the file containing the authentication token -
--pypi-keyring-provider <PYPI_KEYRING_PROVIDER>
— Specifies if we want to use uv keyring providerPossible values:
disabled
,subprocess
-
--change-ps1 <CHANGE_PS1>
— Do not change the PS1 variable when starting a promptPossible values:
true
,false
magic project
Modify the project configuration file through the command line
Usage: magic project [OPTIONS] <COMMAND>
Subcommands:
channel
— Commands to manage project channelsdescription
— Commands to manage project descriptionplatform
— Commands to manage project platformsversion
— Commands to manage project versionenvironment
— Commands to manage project environments
Options:
--manifest-path <MANIFEST_PATH>
— The path to 'pixi.toml' or 'pyproject.toml'
magic project channel
Commands to manage project channels
Usage: magic project channel [OPTIONS] <COMMAND>
Subcommands:
add
— Adds a channel to the project file and updates the lockfilelist
— List the channels in the project fileremove
— Remove channel(s) from the project file and updates the lockfile
Options:
--manifest-path <MANIFEST_PATH>
— The path to 'pixi.toml' or 'pyproject.toml'
magic project channel add
Adds a channel to the project file and updates the lockfile
Usage: magic project channel add [OPTIONS] <CHANNEL>...
Arguments:
<CHANNEL>
— The channel name or URL
Options:
--no-install
— Don't update the environment, only modify the manifest and the lock-file-f
,--feature <FEATURE>
— The name of the feature to modify
magic project channel list
List the channels in the project file
Usage: magic project channel list [OPTIONS]
Options:
--urls
— Whether to display the channel's names or urls
magic project channel remove
Remove channel(s) from the project file and updates the lockfile
Usage: magic project channel remove [OPTIONS] <CHANNEL>...
Arguments:
<CHANNEL>
— The channel name or URL
Options:
--no-install
— Don't update the environment, only modify the manifest and the lock-file-f
,--feature <FEATURE>
— The name of the feature to modify
magic project description
Commands to manage project description
Usage: magic project description [OPTIONS] <COMMAND>
Subcommands:
get
— Get the project descriptionset
— Set the project description
Options:
--manifest-path <MANIFEST_PATH>
— The path to 'pixi.toml' or 'pyproject.toml'
magic project description get
Get the project description
Usage: magic project description get
magic project description set
Set the project description
Usage: magic project description set <DESCRIPTION>
Arguments:
<DESCRIPTION>
— The project description
magic project platform
Commands to manage project platforms
Usage: magic project platform [OPTIONS] <COMMAND>
Subcommands:
add
— Adds a platform(s) to the project file and updates the lockfilelist
— List the platforms in the project fileremove
— Remove platform(s) from the project file and updates the lockfile
Options:
--manifest-path <MANIFEST_PATH>
— The path to 'pixi.toml' or 'pyproject.toml'
magic project platform add
Adds a platform(s) to the project file and updates the lockfile
Usage: magic project platform add [OPTIONS] <PLATFORM>...
Arguments:
<PLATFORM>
— The platform name(s) to add
Options:
--no-install
— Don't update the environment, only add changed packages to the lock-file-f
,--feature <FEATURE>
— The name of the feature to add the platform to
magic project platform list
List the platforms in the project file
Usage: magic project platform list
magic project platform remove
Remove platform(s) from the project file and updates the lockfile
Usage: magic project platform remove [OPTIONS] <PLATFORM>...
Arguments:
<PLATFORM>
— The platform name(s) to remove
Options:
--no-install
— Don't update the environment, only remove the platform(s) from the lock-file-f
,--feature <FEATURE>
— The name of the feature to remove the platform from
magic project version
Commands to manage project version
Usage: magic project version [OPTIONS] <COMMAND>
Subcommands:
get
— Get the project versionset
— Set the project versionmajor
— Bump the project version to MAJORminor
— Bump the project version to MINORpatch
— Bump the project version to PATCH
Options:
--manifest-path <MANIFEST_PATH>
— The path to 'pixi.toml' or 'pyproject.toml'
magic project version get
Get the project version
Usage: magic project version get
magic project version set
Set the project version
Usage: magic project version set <VERSION>
Arguments:
<VERSION>
— The new project version
magic project version major
Bump the project version to MAJOR
Usage: magic project version major
magic project version minor
Bump the project version to MINOR
Usage: magic project version minor
magic project version patch
Bump the project version to PATCH
Usage: magic project version patch
magic project environment
Commands to manage project environments
Usage: magic project environment [OPTIONS] <COMMAND>
Subcommands:
add
— Adds an environment to the manifest filelist
— List the environments in the manifest fileremove
— Remove an environment from the manifest file
Options:
--manifest-path <MANIFEST_PATH>
— The path to 'pixi.toml' or 'pyproject.toml'
magic project environment add
Adds an environment to the manifest file
Usage: magic project environment add [OPTIONS] <NAME>
Arguments:
<NAME>
— The name of the environment to add
Options:
-
-f
,--feature <FEATURES>
— Features to add to the environment -
--solve-group <SOLVE_GROUP>
— The solve-group to add the environment to -
--no-default-feature
— Don't include the default feature in the environmentDefault value:
false
-
--force
— Update the manifest even if the environment already existsDefault value:
false
magic project environment list
List the environments in the manifest file
Usage: magic project environment list
magic project environment remove
Remove an environment from the manifest file
Usage: magic project environment remove <NAME>
Arguments:
<NAME>
— The name of the environment to remove
magic task
Interact with tasks in the project
Usage: magic task [OPTIONS] <COMMAND>
Subcommands:
add
— Add a command to the projectremove
— Remove a command from the projectalias
— Alias another specific commandlist
— List all tasks in the project
Options:
--manifest-path <MANIFEST_PATH>
— The path to 'pixi.toml' or 'pyproject.toml'
magic task add
Add a command to the project
Usage: magic task add [OPTIONS] <NAME> <COMMANDS>...
Arguments:
<NAME>
— Task name<COMMANDS>
— One or more commands to actually execute
Options:
--depends-on <DEPENDS_ON>
— Depends on these other commands-p
,--platform <PLATFORM>
— The platform for which the task should be added-f
,--feature <FEATURE>
— The feature for which the task should be added--cwd <CWD>
— The working directory relative to the root of the project--env <ENV>
— The environment variable to set, use --env key=value multiple times for more than one variable--description <DESCRIPTION>
— A description of the task to be added--clean-env
— Isolate the task from the shell environment, and only use the magic environment to run the task
magic task remove
Remove a command from the project
Usage: magic task remove [OPTIONS] [NAMES]...
Arguments:
<NAMES>
— Task names to remove
Options:
-p
,--platform <PLATFORM>
— The platform for which the task should be removed-f
,--feature <FEATURE>
— The feature for which the task should be removed
magic task alias
Alias another specific command
Usage: magic task alias [OPTIONS] <ALIAS> <DEPENDS_ON>...
Arguments:
<ALIAS>
— Alias name<DEPENDS_ON>
— Depends on these tasks to execute
Options:
-p
,--platform <PLATFORM>
— The platform for which the alias should be added--description <DESCRIPTION>
— The description of the alias task
magic task list
List all tasks in the project
Usage: magic task list [OPTIONS]
Options:
-s
,--summary
— Tasks available for this machine per environment-e
,--environment <ENVIRONMENT>
— The environment the list should be generated for. If not specified, the default environment is used
magic list
List project's packages.
Highlighted packages are explicit dependencies.
Usage: magic list [OPTIONS] [REGEX]
Arguments:
<REGEX>
— List only packages matching a regular expression
Options:
-
--platform <PLATFORM>
— The platform to list packages for. Defaults to the current platform -
--json
— Whether to output in json format -
--json-pretty
— Whether to output in pretty json format -
--sort-by <SORT_BY>
— Sorting strategyDefault value:
name
Possible values:
size
,name
,kind
-
--manifest-path <MANIFEST_PATH>
— The path to 'pixi.toml' or 'pyproject.toml' -
--frozen
— Install the environment as defined in the lockfile, doesn't update lockfile if it isn't up-to-date with the manifest file -
--locked
— Check if lockfile is up-to-date before installing the environment, aborts when lockfile isn't up-to-date with the manifest file -
-e
,--environment <ENVIRONMENT>
— The environment to list packages for. Defaults to the default environment -
--no-lockfile-update
— Don't update lockfile, implies the no-install as well -
--no-install
— Don't modify the environment, only modify the lock-file -
--tls-no-verify
— Do not verify the TLS certificate of the server -
--auth-file <AUTH_FILE>
— Path to the file containing the authentication token -
--pypi-keyring-provider <PYPI_KEYRING_PROVIDER>
— Specifies if we want to use uv keyring providerPossible values:
disabled
,subprocess
-
-x
,--explicit
— Only list packages that are explicitly defined in the project
magic tree
Show a tree of project dependencies
Dependency names highlighted in green are directly specified in the manifest. Yellow version numbers are conda packages, PyPI version numbers are blue.
Usage: magic tree [OPTIONS] [REGEX]
Arguments:
<REGEX>
— List only packages matching a regular expression
Options:
-
-p
,--platform <PLATFORM>
— The platform to list packages for. Defaults to the current platform -
--manifest-path <MANIFEST_PATH>
— The path to 'pixi.toml' or 'pyproject.toml' -
-e
,--environment <ENVIRONMENT>
— The environment to list packages for. Defaults to the default environment -
--no-lockfile-update
— Don't update lockfile, implies the no-install as well -
--no-install
— Don't modify the environment, only modify the lock-file -
--tls-no-verify
— Do not verify the TLS certificate of the server -
--auth-file <AUTH_FILE>
— Path to the file containing the authentication token -
--pypi-keyring-provider <PYPI_KEYRING_PROVIDER>
— Specifies if we want to use uv keyring providerPossible values:
disabled
,subprocess
-
-i
,--invert
— Invert tree and show what depends on given package in the regex argument
magic global
Subcommand for global package management actions
Install packages on the user level. Example: magic global install my_package magic global remove my_package
Usage: magic global <COMMAND>
Subcommands:
install
— Installs the defined package in a global accessible locationremove
— Removes a package previously installed into a globally accessible location viamagic global install
list
— Lists all packages previously installed into a globally accessible location viamagic global install
upgrade
— Upgrade specific package which is installed globallyupgrade-all
— Upgrade all globally installed packages
magic global install
Installs the defined package in a global accessible location
Usage: magic global install [OPTIONS] [PACKAGES]...
Arguments:
<PACKAGES>
— Specifies the packages that are to be installed
Options:
-
-c
,--channel <CHANNEL>
— The channels to consider as a name or a url. Multiple channels can be specified by using this field multiple times.When specifying a channel, it is common that the selected channel also depends on the
conda-forge
channel.By default, if no channel is provided,
conda-forge
is used. -
-p
,--platform <PLATFORM>
Default value:
osx-arm64
-
--tls-no-verify
— Do not verify the TLS certificate of the server -
--auth-file <AUTH_FILE>
— Path to the file containing the authentication token -
--pypi-keyring-provider <PYPI_KEYRING_PROVIDER>
— Specifies if we want to use uv keyring providerPossible values:
disabled
,subprocess
magic global remove
Removes a package previously installed into a globally accessible location via magic global install
Usage: magic global remove [OPTIONS] [PACKAGES]...
Arguments:
<PACKAGES>
— Specifies the packages that are to be removed
Options:
-v
,--verbose
— Increase logging verbosity-q
,--quiet
— Decrease logging verbosity
magic global list
Lists all packages previously installed into a globally accessible location via magic global install
Usage: magic global list
magic global upgrade
Upgrade specific package which is installed globally
Usage: magic global upgrade [OPTIONS] <SPECS>...
Arguments:
<SPECS>
— Specifies the packages to upgrade
Options:
-
-c
,--channel <CHANNEL>
— The channels to consider as a name or a url. Multiple channels can be specified by using this field multiple times.When specifying a channel, it is common that the selected channel also depends on the
conda-forge
channel.By default, if no channel is provided,
conda-forge
is used. -
--platform <PLATFORM>
— The platform to install the package forDefault value:
osx-arm64
magic global upgrade-all
Upgrade all globally installed packages
Usage: magic global upgrade-all [OPTIONS]
Options:
-
-c
,--channel <CHANNEL>
— The channels to consider as a name or a url. Multiple channels can be specified by using this field multiple times.When specifying a channel, it is common that the selected channel also depends on the
conda-forge
channel.By default, if no channel is provided,
conda-forge
is used. -
--tls-no-verify
— Do not verify the TLS certificate of the server -
--auth-file <AUTH_FILE>
— Path to the file containing the authentication token -
--pypi-keyring-provider <PYPI_KEYRING_PROVIDER>
— Specifies if we want to use uv keyring providerPossible values:
disabled
,subprocess
-
--platform <PLATFORM>
— The platform to install the package forDefault value:
osx-arm64
magic config
Configuration management
Usage: magic config <COMMAND>
Subcommands:
edit
— Edit the configuration filelist
— List configuration valuesprepend
— Prepend a value to a list configuration keyappend
— Append a value to a list configuration keyset
— Set a configuration valueunset
— Unset a configuration value
magic config edit
Edit the configuration file
Usage: magic config edit [OPTIONS]
Options:
-l
,--local
— Operation on project-local configuration-g
,--global
— Operation on global configuration-s
,--system
— Operation on system configuration
magic config list
List configuration values
Example: magic config list default-channels
Usage: magic config list [OPTIONS] [KEY]
Arguments:
<KEY>
— Configuration key to show (all if not provided)