Skip to content

Commit

Permalink
max_attempts should only use n_installed if >0 (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimergp authored Dec 12, 2023
1 parent 6d61b0f commit a550184
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions conda_libmamba_solver/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def _max_attempts(self, in_state: SolverInputState, default: int = 1):
return installed_count
else:
return max_attempts_from_env
elif in_state.update_modifier.FREEZE_INSTALLED:
elif in_state.update_modifier.FREEZE_INSTALLED and installed_count:
# this the default, but can be overriden with --update-specs
# we cap at MAX_SOLVER_ATTEMPTS_CAP attempts to avoid things
# getting too slow in large environments
Expand Down Expand Up @@ -314,6 +314,7 @@ def _solving_loop(
for_history=dict(out_state.for_history),
neutered=dict(out_state.neutered),
conflicts=dict(out_state.conflicts),
pins=dict(out_state.pins),
)
if not solved:
log.debug("Last attempt: reporting all installed as conflicts")
Expand All @@ -335,7 +336,7 @@ def _solving_loop(
self._command = "last_solve_attempt"
else:
self._command += "+last_solve_attempt"
solved = self._solve_attempt(in_state, out_state, index)
solved = self._solve_attempt(in_state, out_state, index, attempt=attempt + 1)
if not solved:
message = self._prepare_problems_message(pins=out_state.pins)
exc = LibMambaUnsatisfiableError(message)
Expand Down
2 changes: 1 addition & 1 deletion news/394-max-attempts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Enhancements

* Add some boundary checks to `CONDA_LIBMAMBA_SOLVER_MAX_ATTEMPTS`. (#394)
* Add some boundary checks to `CONDA_LIBMAMBA_SOLVER_MAX_ATTEMPTS`. (#394, #403)

### Bug fixes

Expand Down

0 comments on commit a550184

Please sign in to comment.