How to move .conda from one folder to another at the moment of creating the environment

Configure Environment and Package Default Locations

I’d guess that, despite your efforts to put your environments on the large partition, there is still a default user-level package cache and that is filling up the home partition. At minimum, set up a new package cache and a default environments directory on the large partition:

# create a new pkgs_dirs (wherever, doesn't have to be hidden)
mkdir -p /big_partition/users/user/.conda/pkgs

# add it to Conda as your default
conda config --add pkgs_dirs /big_partition/users/user/.conda/pkgs

# create a new envs_dirs (again wherever)
mkdir -p /big_partition/users/user/.conda/envs

# add it to Conda as your default
conda config --add envs_dirs /big_partition/users/user/.conda/envs

Now you don’t have to fuss around with using the --prefix flag any more – your named environments (conda create -n foo) will by default be created inside this directory and you can activate by name instead of directory (conda activate foo).

Transferring Previous Environments and Package Cache

Unfortunately, there’s not a great way to move Conda environments across filesystems without destroying the hardlinks. Instead, you’ll need to recreate your environments. Since you may or may not want to bother with this, I’m only going to outline it. I can elaborate if needed.

  1. Archive environments. Use conda env export -n foo > foo.yaml (One per environment.)
  2. Move package cache. Copy contents of old package cache (/home/users/user_name/.conda/envs/.pkgs/) to new package cache.
  3. Recreate environments. Use conda env create -n foo -f foo.yaml.

Again, you could just skip this altogether. This is mainly if you want to be very thorough about transferring and not having to redownload stuff for environments you already created.

After this you can delete some the stuff under the old ~/.conda/envs/pkgs folder.

Leave a Comment