Conda CLI Usage

Conda CLI Usage

Use the Conda CLI to download packages through Nexus Repository after you create the repository and configure the Conda client. When authenticated access is required, include credentials in the repository URL. Nexus Repository then retrieves packages from the remote Conda repository, caches them, and returns the cached content to the client.

Download Packages

Download packages from your Nexus Repository Conda repository by using the conda install command with the repository URL:

conda install -c <protocol>://<user>:<password>@<hostname>:<port>/repository/<repository_name> <package_name>

Where:

Example:

conda install -c https://admin:admin123@nexus.example.com:8081/repository/conda-proxy numpy

If Nexus Repository requires authentication, append the credentials to the repository URL.

Retrieve Conda Content

After you configure the Conda client to use Nexus Repository, run Conda commands as usual from your environment. The following commands use Nexus Repository to retrieve package information and package content:

Example:

$ conda install numpy

Upload Conda Packages

To upload packages to a Conda hosted repository, use an HTTP PUT request with CURL. The upload path includes the target channel and architecture for the package.

curl -u <username>:<password> -X PUT \
  --upload-file <package_file> \
  https://<hostname>/repository/<repository_name>/<channel>/<architecture>/<package_file>

Where:

Example:

curl -u admin:admin123 -X PUT \
  --upload-file scipy-1.7.3-py310_0.conda \
  https://nexus.example.com/repository/conda-hosted/myproject/osx-arm64/scipy-1.7.3-py310_0.conda

Example for uploading multiple packages:

#!/bin/bash
NEXUS_URL="https://nexus.example.com/repository/conda-hosted"
CHANNEL="main"
ARCH="linux-64"
USERNAME="admin"
PASSWORD="admin123"

for package in *.tar.bz2 *.conda; do
  if [ -f "$package" ]; then
    echo "Uploading $package..."
    curl -u "$USERNAME:$PASSWORD" -X PUT \
      --upload-file "$package" \
      "$NEXUS_URL/$CHANNEL/$ARCH/$package"
  fi
done

Example when using bearer token for authentication:

curl -H "Authorization: Bearer YOUR_TOKEN" -X PUT \
  --upload-file package.tar.bz2 \
  https://nexus.example.com/repository/conda-hosted/main/linux-64/package.tar.bz2

After a successful upload, Nexus Repository automatically updates repository metadata.