Modifying an existing stack's conda environment

Due to the way we currently install the conda environment, a user may experience issues when trying to augment their environment.

This is a known issue, with a cause that is subtle and internal to conda. We currently use a method where periodically create an environment from an abstract file (the “bleed” files), which we then store the output from conda list --explicit, and use that output to later install the conda environment for the stack. This has the side-effect of writing out the specs of what was installed, down to the build string, to $CONDA_PREFIX/conda-meta/history, which the conda command consults when attempting to solve for a package. This, with current implementation of conda, tends to be really slow when trying to form a solution.

So what to do about it?

First off - if you are able to solve, say within 15 minutes or so, it might not be worth the headache to attempt the steps below. If you are really unable to install anything in your environment and you really need to, then consider the steps below.

To mitigate this, we plan to migrate to using the rubin-env metapackage in conda-forge to install the dependencies, where the recipe to build that metapackage contains constraints on certain packages (but much less overall). This will give the conda command a bit more flexibility in finding a solution and should generally lead to faster install times.

But we are currently not using rubin-env. So what can you do in the near term?

You can sort of approximate the behavior by writing out by performing these steps, from an an activated conda environment for the stack:

Note: These methods may modify your environment in a way which could render your environment incompatible with the LSST software stack.

If you have questions, feel free to ask.

# 1. truncate history file. This removes requirements, down to the build string, from being considered
cat /dev/null > $CONDA_PREFIX/conda-meta/history

# 2.
# a) find version constraints in a bleed file
# The bleed file for linux is here:
# You should be able to ignore the pyqt and sysroot constraints for now.
# b) Create a pinned file from the constraints:
cat <<EOF > $CONDA_PREFIX/conda-meta/pinned
flake8 <3.8
mpich =3.2.1
pytest <6
pytest-doctestplus !=0.7.0
pytest-session2file !=0.1.10
boost =1.70
click <7.1
fastavro <0.24
matplotlib =3.0
pybind11 <2.3

# Optional: Use mamba to install things
# mamba is a drop-in replacement for conda rewritten in C++ using libsolv
# It is often much faster, but incomplete and considered beta software by the authors.
# Here, we install it in the base environment
conda install -n base -c conda-forge --yes mamba

At this point, you should be able to conda install ipython or whatever else you may need to install and get a solution faster, or try out mamba install ipython if you installed mamba.

Please note that these instructions may soon be outdated and are not definitive. I am including them only to report what I have had some success with when encountering this issue.