How to change location of conda's environments.txt file

Viewed 48

I am attempting to move conda data to .local/share as to not clutter my home. My conda configuration file, located at home/user/.config/conda/condarc is the following:

envs_dirs:
  - /home/user/.local/share/conda/local_envs/

pkgs_dirs:
  - /home/user/.local/share/conda/env_pkgs/

auto_activate_base: false

with this in place I expect created environments to store data in /home/user/.local/share/conda/local_envs/, which happens to be the case. The problem that I am trying to fix is that to keep track of these envs conda creates a directory /home/.conda containing the environments.txt file, which just lists all existing envs. I don't want this directory to be created, but am failing to change this behaviour.

The output of conda config --show lists the following envs_dirs path, which might be related to the issue:

envs_dirs:
  - /home/user/.local/share/conda/local_envs
  - /home/user/.local/share/conda/envs
  - /home/user/.conda/envs

This is weird considering that only one of these is listed in my condarc, such that atttempt to remove the unwanted paths (conda config --remove envs_dirs /home/gala/.conda/envs) give the following error

CondaKeyError: 'envs_dirs': key 'envs_dirs' is not in the config file
1 Answers

Not currently possible. The pertinent Conda code is

def get_user_environments_txt_file(userhome='~'):
    return expand(join(userhome, '.conda', 'environments.txt'))

and all the references to this call it with no argument. So there isn't any way in Conda to avoid this.

If you would like this to change, file an Issue on the repository. This existing Issue seems like a good place to chime it and propose some functionality to manage it.

Symlinking

If you really don't want it tracked, you might get away with a symlink to /dev/null:

ln -s /dev/null ~/.conda/environments.txt

Alternatively, you could symlink to a real file at another location. Not sure that has any advantage though - you still have the symlink in your user home.

Related