6

https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html

I understand that

You can make an exact copy of an environment by creating a clone of it:

conda create --name myclone --clone myenv

where myenv is an existing environment.

How is conda create --clone different from copying the environment directory directly into new location?

kgf3JfUtW
  • 11,626
  • 7
  • 46
  • 72

1 Answers1

12

Conda maintains hardlinks to reduce physical disk usage. Normal copying will simply make physical duplicates, wasting a bunch of space unnecessarily.

The most problematic issue is that of files that include absolute paths. Copying alone would result in coupling to the original environment in a cryptic way. This could lead to changes in the original environment implicitly affecting the copied one. There is the conda-prefix-replacement tool for use in rewiring these absolute links.1

Lastly, there are also packages that run post-link installation scripts. Copying wouldn't be running these, which could lead to undefined behavior.


[1]: An historical note might be of interest to some - especially for this oh-so-appropriately named piece of software. This tool (cpr) arose from a major breakage in Anaconda when MacOS users upgraded to Catalina (10.15) (see blog post). Older installers of Anaconda would sometimes use /anaconda as the installation directory, but Apple made creating folders in system volume root off-limits in MacOS 10.15. This resulted in users' Anaconda installations getting moved during the upgrade, and ultimately breaking them. The cpr tool thus provided a mean of resuscitating these incapacitated Conda installations.

merv
  • 53,208
  • 11
  • 148
  • 196
  • 1
    +1, ran into a bunch of issues when an environment I copied into a new location still had shebangs referring to the original location, and the environment wouldn't work from the new location – axolotl Sep 30 '21 at 15:37
  • A nightmare in a multiuser cluster every time somebody wants to install something that requires Conda itself to be updated. I opted for telling my users to do a local installation of miniconda. – runlevel0 Oct 01 '21 at 11:36