~/.conda/envs 与 ~/anaconda3/envs

~/.conda/envs vs. ~/anaconda3/envs

我最近在更新 macOS Catalina 后调试了 Anaconda 的一些问题,并注意到 ~/.conda/envs 已添加到配置中。这已经破坏了我的许多开发环境,我想知道...

为什么我会看到 conda 环境的这个新位置?我可以删除它并继续在 ~/anaconda3/envs 中单独使用和创建环境吗?

conda info
...
envs directories : /Users/me/.conda/envs
                   /Users/me/anaconda3/envs
...

根据this GitHub issue~/.conda/envs的目的是为conda提供至少一个保证用户可写的目录

The ~/.conda directory is no longer used on Windows, only unix. Conda's install location is not guaranteed to be user-writable. Conda always needs at least one user-writable location for the package cache (pkgs directory) and the envs directory where new named environments are created. The default location for these directories is ~/.conda on unix, and on Windows we use appdirs. The ~/.conda directory has been used for years on unix for this purpose.

When conda's install location is user-writable, then that's the location chosen as "first writable" for these two directories. When conda's install location is not writable by the current user, then conda uses the ~/.conda directory as the writable location, but is still able to use the install location for a read-only package cache and named environments. Compare output of conda config --show for the two different cases.

The locations of these directories can be overrode by configuration using the envs_dirs and pkgs_dirs configuration parameters, or CONDA_ENVS_DIRS and CONDA_PKGS_DIRS environment variables.

只将环境安装到 ~/anaconda3/envs 应该是安全的,只要当前用户可写即可。例如,我只将环境安装到 ~/miniconda3/envs 中并且没有遇到任何问题。