conda-lock icon indicating copy to clipboard operation
conda-lock copied to clipboard

Remove packages that are removed from input file from lock file

Open Riezebos opened this issue 2 years ago • 2 comments

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?

Riezebos avatar Sep 21 '22 22:09 Riezebos

In general package removal is a very complex thing. You're better of just deleting the lock file and regenerating entirely.

mariusvniekerk avatar Sep 22 '22 01:09 mariusvniekerk

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

Riezebos avatar Sep 22 '22 07:09 Riezebos

@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.

riccardoporreca avatar Sep 23 '22 15:09 riccardoporreca

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.

jonmoore avatar Oct 09 '22 15:10 jonmoore

Just wanted to note this is a duplicate of https://github.com/conda-incubator/conda-lock/issues/196

scottyhq avatar Nov 04 '22 18:11 scottyhq