LinuxCommandLibrary

conda-compare

Compare two Conda environments

TLDR

Compare packages in the current directory to packages from the file file.yml

$ conda compare file.yml
copy

Compare packages in environment named myenv to packages from the file file.yml
$ conda compare [[-n|--name]] myenv [path/to/file.yml]
copy

Compare packages in environment myenv at custom path (i.e. prefix) to packages from the file file.yml
$ conda compare [[-p|--prefix]] [path/to/myenv] [path/to/file.yml]
copy

Display help
$ conda create [[-h|--help]]
copy

SYNOPSIS

conda compare SOURCE1 SOURCE2 [OPTIONS]
SOURCE can be an environment name, path to an environment, or path to an environment.yml file.

PARAMETERS

SOURCE1 SOURCE2
    Paths to environments, environment names, or paths to environment.yml files that are to be compared.

-f, --file
    Instructs conda-compare to interpret both SOURCE1 and SOURCE2 as paths to environment.yml files, rather than environment names or prefixes.

-j, --json
    Outputs the comparison results in a structured JSON format, suitable for programmatic parsing.

--no-builds
    Ignores the package build string during comparison, focusing solely on package name and version.

--no-platform
    Disregards the platform information when comparing packages, useful for cross-platform comparisons.

--no-channel
    Omits channel information from the comparison, only considering package name and version.

--strict
    If any differences are detected between the environments, the command will exit with a non-zero status code (1), making it ideal for automation scripts and CI/CD checks.

DESCRIPTION

conda-compare is a powerful utility designed to highlight differences between Conda environments or their definition files. It systematically analyzes and reports disparities in installed packages, their versions, and associated channels. This tool is indispensable for maintaining consistency across various stages of development—from local workstations to production servers—and for debugging complex dependency conflicts. Users can compare two active environments, two environment.yml files, or an environment against a file. By presenting a clear, often color-coded, output, conda-compare simplifies the task of identifying what has been added, removed, or changed. It significantly aids in ensuring environment reproducibility, collaborating on projects, and validating environment integrity within CI/CD pipelines. It functions as a subcommand after installing the conda-env-compare package.

CAVEATS

conda-compare requires the conda-env-compare package to be installed separately. While powerful, it primarily compares packages and their metadata, and might not capture differences in non-package-related environment settings (e.g., custom environment variables set outside environment.yml or by activate scripts). Comparing very large environments can be resource-intensive and time-consuming.

INSTALLATION

To use conda-compare, you must first install the conda-env-compare package. This can typically be done using the following command:
conda install conda-env-compare

OUTPUT INTERPRETATION

By default, conda-compare provides a human-readable, color-coded output that visually distinguishes added, removed, and changed packages. For example, green often indicates additions, red for removals, and yellow for changes in version or build. When the --json flag is used, the output shifts to a machine-readable JSON object, ideal for integration into automated workflows or custom reporting tools.

HISTORY

conda-compare is not an intrinsic part of the core conda distribution but is provided by the separately maintained conda-env-compare package. Its development arose from the community's need for a more sophisticated environment comparison tool than simple diff operations on conda env export outputs. It was created to offer a purpose-built, intelligent comparison specifically tailored for the intricacies of Conda environments. Its emergence reflects the increasing demand for robust reproducibility and efficient environment management within data science and scientific computing, quickly establishing itself as a valuable extension to the Conda ecosystem.

SEE ALSO

conda(1), conda env(1), conda list(1), diff(1)

Copied to clipboard