conda-lock
conda-lock copied to clipboard
Remove packages that are removed from input file from lock file
If I remove a package from environment.yml
and then run:
conda-lock lock -f environment.yml --check-input-hash
I would expect that the removed package is also removed from the conda-lock.yml file. This currently seems to not be the case. Would it be possible to add a flag that automatically removes the packages that are not in the input file anymore?
In general package removal is a very complex thing. You're better of just deleting the lock file and regenerating entirely.
That's what I did now. Would it be possible to let conda-lock regenerate the lock file with a flag or to throw an exception with a flag in the case that there are more packages than expected?
I am trying to integrate conda-lock in our pre-commit and CI/CD pipeline. If someone makes any change to environment.yml without also updating conda-lock.yml I would like our CI/CD pipeline to fail. --check-input-hash
is great! Having some kind of different message/exit code/behavior if a package is removed from input would make it even better
@mariusvniekerk, @Riezebos, note that this can bite beyond removing a direct dependency listed explicitly in any of the source files. Upgrading dependencies might drop some transitive dependencies, which would still be kept in the lockfile and might start conflicting with the "real" consistent dependencies resolved by conda-lock, which conda would complain about when creating an environment with all locked dependencies.
Out of curiosity, @mariusvniekerk, would you comment on the different behavior of running conda-lock
with / without an existing lockfile when there are changes to the source files?
If a lockfile exists, I would imagine conda-lock tries to keep at the locked version what is still consistent with the new dependencies, but I am not too sure about this.
The current behavior is very surprising and not in line with how most developer tools work, i.e. outputs depend only on inputs, not previous outputs.
It would be best to have the behavior prominently described in —help and an option added for clean regeneration. I also think clean regeneration should be the default, although that’s more debatable.
Just wanted to note this is a duplicate of https://github.com/conda-incubator/conda-lock/issues/196