How to update Miniforge and the packages installed from conda-forge?

I installed Miniforge like this:

$ curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
$ bash Miniforge3-$(uname)-$(uname -m).sh

Then I installed the sage package like this:

$ mamba create -n sage sage python=3.11

And then:

$ mamba activate sage

Questions:

  • How do I update Miniforge ?
  • How do I update sage ?
  • Is there a command that updates Miniforge+sage ? basically everything ?

Many Thanks

Once a Miniforge is installed, it’s capable of upgrading any package within its base… but typically one only really needs to upgrade the things actually used from it, e.g. mamba and its dependencies:

mamba upgrade mamba

As for created environments, it’s possible to use mamba upgrade for each “interesting” package interactively, but a more predictable approach is to use an environment.yml file:

channels:
  - conda-forge
dependencies:
  - sage
  - python ==3.11.*

Then:

mamba env update -n sage --file environment.yml

Indeed, this can be the only command one really needs to master (beyond activate) , as if the sage environment were to not exist, it would be created from scratch.

Some more questions:

  • So Miniforge consists of mamba and conda that are pre-configured to work with conda-forge ?
  • The upgrade and update commands do the same thing ?
  • What does mamba update --all do ? Will it update mamba and sage both ?
  • In my case should I just do the following:?
mamba update mamba
mamba update sage

So Miniforge consists of mamba and conda that are pre-configured to work with conda-forge ?

yes.

The upgrade and update commands do the same thing ?

no.

They both do something to an environment, specified with --name or --prefix. mamba upgrade takes a list of package specs at the command line, while mamba env update uses a file.

What does mamba update --all do ?

--all will update everything, potentially python or other things you might not anticipate.

Will it update mamba and sage both ?

no.

No single command invocation (to my knowledge) will act on two different environments.

do the following:?

no.

I think what is requested would be more like:

  • mamba upgrade -n base mamba
  • mamba upgrade -n sage sage

These subtle differences are why I recommend working with mamba env update as the single, reproducible, version-control-friendly way to keep environments in an expected state.

ok, one more question:

in short, mamba update --all updates ALL environments with all the packages in them.

whereas, mamba update -n sage --all updates ALL packages in the sage environment.

whereas, mamba update -n sage sage updates only the sage package in the sage environment.

is my understanding correct ?


Should I even update everything ? I just want to have the latest version of sage.

Many Thanks

No, I don’t think so – mamba update --all updates all the packages in current environment – if you haven’t activated anything, that would be the base environment.

yes. You can accomplish the same thing with:

conda activate sage
conda (or mamba) update --all

[*]

To be clear: conda (and mamba) are all about environments. As a rule, you don’t want to use the base environment for anything other than running the system.

So: If you want to update (or add to , or …) your sage environment – then activate it and do your updating there. If you want to update the minforge system, THEN you update the base environment.

So you’ve done the right thing by creating a “sage” environment in which to run sage. If that’s mostly what you do – you may want to set up your system to automatically active the sage environment when you log in – then it will be ready to go, and you won’t accidentally mess with the base environment by accident.

HTH,
-CHB

[*] I’m pretty sure that miniforge is set up with conda using the “mamba solver” – and the faster solver is really the advantage of mamba over conda – so when I use miniforge, I just use plain old conda.

1 Like

so first update sage and then base ? it should be in that order ?
Do I even need to update base ? what happens if I never update it ?

update base first, if you are going to, but you dont need to do that often.

Updating base will get you the latest conda/mamba, etc.

You should get a message if it gets too out of date.