fix: Explain unsolvable updates (#3829)

This commit is contained in:
k-collie 2025-02-19 08:17:29 +00:00 committed by GitHub
parent 80019ba423
commit 746360cb15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 0 deletions

View File

@ -200,6 +200,14 @@ namespace mamba
auto outcome = solver::libsolv::Solver().solve(db, request).value();
if (auto* unsolvable = std::get_if<solver::libsolv::UnSolvable>(&outcome))
{
unsolvable->explain_problems_to(
db,
LOG_ERROR,
{
/* .unavailable= */ ctx.graphics_params.palette.failure,
/* .available= */ ctx.graphics_params.palette.success,
}
);
if (ctx.output_params.json)
{
Console::instance().json_write({ { "success", false },

View File

@ -216,6 +216,19 @@ class TestUpdate:
else:
assert "To activate this environment, use:" not in res
def test_update_explains_problems(self, env_created):
# Non-regression test for: https://github.com/mamba-org/mamba/issues/3828
with pytest.raises(helpers.subprocess.CalledProcessError) as e:
helpers.update("-n", TestUpdate.env_name, "xtensor=0.24.5", "xtensor=0.25.0")
err_string = str(e.value.stderr.decode("utf-8"))
assert "The following packages are incompatible" in err_string
def test_update_explains_problems_json(self, env_created):
with pytest.raises(helpers.subprocess.CalledProcessError) as e:
helpers.update("-n", TestUpdate.env_name, "xtensor=0.24.5", "xtensor=0.25.0", "--json")
out_string = str(e.value.stdout.decode("utf-8"))
assert "cannot install both" in out_string
class TestUpdateConfig:
current_root_prefix = os.environ["MAMBA_ROOT_PREFIX"]