Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

conda create --clone v.s. copying the environment directly

Tags:

conda

anaconda

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?

like image 582
kgf3JfUtW Avatar asked Dec 23 '22 18:12

kgf3JfUtW


1 Answers

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.

like image 73
merv Avatar answered Feb 12 '23 15:02

merv