mamba-org / mamba

The Fast Cross-Platform Package Manager
https://mamba.readthedocs.io
BSD 3-Clause "New" or "Revised" License
6.86k stars 353 forks source link

"greedy" update of dependencies #624

Closed adomingues closed 3 years ago

adomingues commented 3 years ago

Dear all,

first of all thank you for mamba! It literally saves hours of work.

I have spotted a behaviour which might be a bug or a feature:

When installing an r-packge in a fairly complex environment, mamba asks to a large number of dependencies:

mamba install -c conda-forge r-ggpubr=0.2.4
(..)
  Summary:                                                                                              

  Install: 22 packages                                                                                  
  Change: 104 packages                                                           
  Upgrade: 205 packages 

However I am asking for a specific version of the package which I know it should not need any updates for dependencies - I have the same environment in a separate machine with said package. Furthermore, if I try to install the package with conda install no dependencies are installed (as expected):

conda install -c conda-forge r-ggpubr=0.2.4

==> WARNING: A newer version of conda exists. <==                           
  current version: 4.9.1                        
  latest version: 4.9.2

  added / updated specs:
    - r-ggpubr=0.2.4                                                                                        

The following packages will be downloaded:                                  

    package                    |            build                       
    ---------------------------|-----------------                          
    r-ggpubr-0.2.4             |    r35h6115d3f_0         1.8 MB  conda-forge
    ------------------------------------------------------------
                                           Total:         1.8 MB

The following NEW packages will be INSTALLED:

  r-ggpubr           conda-forge/noarch::r-ggpubr-0.2.4-r35h6115d3f_0

Is this difference in behaviour between mamba and conda expected? And how do I stop mamba from being so "greedy" with dependencies?

Cheers.

adomingues commented 3 years ago

Hi all,

any news on this?

Cheers, António

wolfv commented 3 years ago

Hi, in my experience mamba isn't usually very "greedy". I think one "trick" is to always use strict channel priority.

Any chance you can reconstruct a test case for this behavior?

adomingues commented 3 years ago

No problem, thank you for looking into this. I will create a fairly complex env but it should only take few minutes to install nonetheless:

conda activate base
conda create -n test_mamba r=3.6 r-base r-tidyverse r-rlang r-rjava r-hdf5r r-essentials r-devtools mamba

conda activate test_mamba
# mamba (0.8.2)
mamba install r-here

And this the summary of the number of packages that will be affected using mamba:

  Summary:

  Install: 59 packages
  Change: 28 packages
  Upgrade: 139 packages
  Downgrade: 2 packages

  Total download: 194 MB

If I now use conda to install that same package this is the output:

conda install r-here

## Package Plan ##

  environment location: /mnt/genomics/envs/test_mamba

  added / updated specs:
    - r-here

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    r-here-0.1                 |    r36h6115d3f_0          35 KB
    ------------------------------------------------------------
                                           Total:          35 KB

The following NEW packages will be INSTALLED:

  r-here             pkgs/r/noarch::r-here-0.1-r36h6115d3f_0

As you can appreciate that a massive difference.

I then set the channel prriority to strict and re-try with mamba:

conda config --set channel_priority strict
mamba install r-here

  Summary:

  Install: 5 packages
  Change: 124 packages
  Upgrade: 25 packages
  Downgrade: 7 packages

  Total download: 154 MB

The numbers change but the behavior is still very different from that of conda install.

If this test case is too complex let me know and I will try to simplify it.

Cheers

wolfv commented 3 years ago

The problem is that r-base is not pinned, and then mamba tries to update r-base to r-base=4.0

You can pin a package by adding r-base 3.6.* to $CONDA_PREFIX/conda-meta/pinned

e.g.

echo "r-base 3.6.*" > $CONDA_PREFIX/conda-meta/pinned

that leads to the same small environment change as with conda.

The other alternative is to specify mamba install r-base=3.6 r-here

For python there is some hard-coded behavior in mamba that "pins" the minor version of python. We should consider doing that for other programming languages such as Ruby and R as well.

wolfv commented 3 years ago

PS: please install mamba into the base environment!

adomingues commented 3 years ago

Thanks a lot @wolfv!

The other alternative is to specify mamba install r-base=3.6 r-here

I will use this for now. If it becomes much of an hassle I will pin.

For python there is some hard-coded behavior in mamba that "pins" the minor version of python. We should consider doing that for other programming languages such as Ruby and R as well.

For me and as user naively expecting similar default behaviors from mamba and conda, this would make sense. Alternately including in the documentation this option of pinning for other languages would also be ok.

PS: please install mamba into the base environment!

Honestly When I first used mama I was doing it, but at some point I thought that I had to install in any new env. Good to know I was wrong.