Skip to content

Commit

Permalink
Fix --force-reinstall (#2601)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoinePrv authored Jun 16, 2023
1 parent 12f100c commit be99482
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 2 additions & 3 deletions libmamba/src/core/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ namespace mamba

// 1. check if spec is already installed
Id needle = pool_str2id(m_pool, ms.name.c_str(), 0);
static Id real_repo_key = pool_str2id(pool, "solvable:real_repo_url", 1);

if (needle && (pool->installed != nullptr))
{
Expand All @@ -94,10 +93,10 @@ namespace mamba
// the data about the channel is only in the prefix_data unfortunately

std::string selected_channel;
if (solvable_lookup_str(s, real_repo_key))
if (const char* str = solvable_lookup_str(s, SOLVABLE_PACKAGER))
{
// this is the _full_ url to the file (incl. abc.tar.bz2)
selected_channel = solvable_lookup_str(s, real_repo_key);
selected_channel = str;
}
else
{
Expand Down
16 changes: 16 additions & 0 deletions micromamba/tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,3 +532,19 @@ def test_broken_package_name(self):
res = install(non_existing_url, default_channel=False)
except subprocess.CalledProcessError as e:
assert "Invalid package filename" in e.stderr.decode("utf-8")

def test_no_reinstall(self, existing_cache):
"""Reinstalling is a no op."""
res = install("xtensor", "--json")
assert "xtensor" in {pkg["name"] for pkg in res["actions"]["LINK"]}

reinstall_res = install("xtensor", "--json")
assert "actions" not in reinstall_res

def test_force_reinstall(self, existing_cache):
"""Force reinstall installs existing package again."""
res = install("xtensor", "--json")
assert "xtensor" in {pkg["name"] for pkg in res["actions"]["LINK"]}

reinstall_res = install("xtensor", "--force-reinstall", "--json")
assert "xtensor" in {pkg["name"] for pkg in reinstall_res["actions"]["LINK"]}

0 comments on commit be99482

Please sign in to comment.