Skip to content

Additional Steps when Conda has been Initialized

Determine root of the base Conda installation

Use the command conda info --base to determine if you have been using Python provided by one of the VACC's python3.xx-anaconda modules or if you are using a self-installed Miniconda package.

Note on use of pre-existing environments

Regardless of whether you used an Anaconda module or Miniconda that you installed yourself, if you plan to use pre-existing environments with Miniforge, you will have to check each environment, in a later step, for use of prohibited channels. Any environments found to have used a restricted Anaconda channel will have to be rebuilt unless it will strictly be used for instructional purposes.

$ conda info --base
/gpfs1/sw/rh9/pkgs/python3.12-anaconda/2024.06-1

If your base path is similar to that shown above, then conda was initialized using one of our python3.xx-anaconda modules. In this case, the default path to your conda environments would be ~/.conda/envs. This is the same directory path used by Miniforge, so you will automatically be able to activate pre-existing environments. Skip the next section, for Miniconda users only, and proceed to Revert Conda Initialization.

$ conda info --base
/users/x/y/myNetID/miniconda3

If the path is, instead, similar to that shown above, then conda was initialized using a self-installed Miniconda package. In this case, the default path to your conda environments is likely ~/miniconda3/envs. Because your previously created environments are not in the default environment path used by Miniforge, you'll have to add the Miniconda path to the Miniforge configuration, as described below, so that the conda provided by Miniforge can find your old environments.

Configure Paths (Miniconda users)

If you wish to access environments previously created using a self-installed Miniconda, you'll need to add the path of Miniconda's environment directory (~/miniconda3/envs) to the Miniforge configuration.

Confirm your current environment path and add it to your configuration. This will create and/or update the file ~/.condarc that is used by Miniforge.

$ conda config --show envs_dirs

# Output should be similar to below:

envs_dirs:
  - /users/x/y/myNetID/miniconda3/envs
  - /users/x/y/myNetID/.conda/envs

# ~/.conda/envs is the default Miniforge environment directory

Add both the ~/miniconda3/envs and ~/.conda/envs paths so that you can specify relative priority. Any new environments created will be saved in the first listed directory, and this should, in most cases, be ~/.conda/envs. When activating a Conda environment, all envs_dirs will be searched in order.

Enter the following commands to add these paths to your Miniforge environment configuration in the correct order:

$ conda config --append envs_dirs ~/.conda/envs
$ conda config --append envs_dirs ~/miniconda3/envs

Similarly, add your Miniconda pkgs path to your Miniforge configuration. This may avoid duplication of files if new environments include any packages that are already installed in pre-existing environments.

$ conda config --append pkgs_dirs ~/.conda/pkgs
$ conda config --append pkgs_dirs ~/miniconda3/pkgs

Revert Conda Initialization

Remove the commands that were added to your ~/.bashrc startup file by conda init to prevent conda from being set up by either Anaconda or Miniconda. You should instead be using Miniforge provided by module (or your own Miniforge installation).

Your startup file was modified by conda init to include all lines of code between, and including, the following two lines:

# >>> conda initialize >>>
# <<< conda initialize <<<

To reverse that process, you can do one of three things:

  • use a text editor to manually comment out all lines of your ~/.bashrc file between the above two lines
  • use a text editor to delete all lines of your ~/.bashrc file between, and including, the above two lines
  • run the conda command below to reverse conda init and automatically clean up your ~/.bashrc file:
$ conda init --reverse

After completing any of the above options, log out and log back in again.

Set up Conda for every login (optional)

If you want the continued experience of having the conda command readily available with every login, you have two options:

Create a Default Module Collection

You can create a "default" Module Collection so that the miniforge module will load automatically for every session. See our documentation page to learn about module collections, and specifically about the default module collection.

This allows you to define a module, or set of modules, that will be automatically loaded on any new session. Simply:

$ module purge
$ module load miniforge/25.11.0-py3.12
$ module save

Once created, to see what modules are in the default module list, you would enter:

$ module describe default

If you use a specific version of a module on the load command (as in the example above), that version will be explicitly added to the default collection. If you use module load miniforge without specifying a version, when creating your default collection, the miniforge module that gets loaded upon login will automatically load the VACC’s default version of that package. When there is more than one version available to load, the default version is usually (but not always) the latest version. What you get upon login, in that case, is subject to change when new versions of that module are added or the default version changes for some other reason.

Add the Miniforge condabin directory to your PATH

Alternatively, you can add the condabin directory provided by Miniforge to your PATH. Running the commands below will modify Your ~/.bashrc file, prepending the condabin directory to your PATH. This will provide the conda and mamba commands for each new login session.

$ module purge
$ module load miniforge
$ conda init --condabin

You must log out and back in again for this change to take effect.

NOTE: Slurm batch jobs are run as non-interactive shells. This means that for batch jobs, the ~/.bashrc file does not get sourced and condabin will not be added to your PATH. If you want to use the conda or mamba command for your job, you will need to do either of the following within your job script:

# Option 1) source your ~/.bashrc file
source ~/.bashrc

# Option 2) load one of the miniforge modules
module load miniforge
Next Step for All Users

Return to the Technical Details page and continue to the section Set up Miniforge.


If you have any questions about the transition, please open a ticket with VACC support by emailing vacchelp@uvm.edu or visit us at one of our Research Computing Virtual Café sessions.