8

It seems micromamba is missing a clone environment option, or is it just named differently?

  • Mamba's help micromamba create -n envname --help does not seem to show any clone-like option and
  • standard conda's conda create -n envname --clone oldenv doesn't seem to work.

If mamba is missing clone option, what is the reason for that?

Thanks!

2 Answers 2

11

Yeah, It does not have a cloning option yet

Minor Update

the command to create the environment failed with micromamba version 1.4.9, use the --file flag,

micromamba env create --name newenv --file oldenv.yaml

-- informed by gkaf

REASON:

It's simply because it is designed as a lightweight, fast, and minimal version of mamba. The clone environment is a relatively complex feature, and it was not considered to be essential for the core functionality of micromamba.

SOLUTION:

There is a roundabout way although. As per I know, you can export the current env as yaml and run micromamba env create to create a env from the yaml file.

Export the contents of the existing environment to a YAML file.

micromamba env export -n oldenv > oldenv.yaml

Create a new environment from the YAML file.

micromamba env create -n newenv -f oldenv.yaml

This should work, notify if it doesn't.

6
  • Minor update: the command to create the environment failed with micromamba version 1.4.9, use the --file flag, micromamba env create --name newenv --file oldenv.yaml.
    – gkaf
    Commented Aug 14, 2023 at 17:44
  • When I run micromamba env export jax-cuda > jax-cuda.yaml I get the error The following argument was not expected: jax-cuda
    – Tom
    Commented Aug 25, 2023 at 20:56
  • What if you try this micromamba env export > jax-cuda.yaml in the old env Commented Aug 28, 2023 at 15:22
  • @Tom original post was missing the -n or --name flag: micromamba env export -n jax-cuda > jax-cuda.yaml
    – tdy
    Commented Sep 8, 2023 at 16:49
  • Does this route use hardlinks, so as not to explode disk usage? Commented Oct 16, 2023 at 21:15
2

Same as Hind Sagar Biswas, micromamba does not provide env clone option yet.

To be honest, I think the simplest method is just copy the entire env folder under envs, like cp -r ~/micromamba/envs/$OLD ~/micromamba/envs/$NEW. After copying, you can see the new env from micromamba env list.

I've tried this approach, and although it seems intuitive and doesn't make sense, it's worked fine so far.

(After understanding how conda organizes files, maybe I can figure out why this works.)


Supplement:

Nowadays(Jun, 2024), I think that it is just a simple way to backup current env instead a good clone approach. Run head -n 1 $(which pip3), and you will know how your binary tools downloaded by pip to locate current env.

1
  • One negative argument is, that this will copy all the data between envs (not using any hardlinks). But if it works, seems like often the best solution (environments are often not that big). Reinstalling environment might be troublesome. Some tools might have been available during installation of first env, but might have different versioning/ broken compatibility now.
    – Smarty77
    Commented Apr 15 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.