diff --git a/micromamba/src/umamba.cpp b/micromamba/src/umamba.cpp index 73268e2725..4280ea8048 100644 --- a/micromamba/src/umamba.cpp +++ b/micromamba/src/umamba.cpp @@ -63,6 +63,13 @@ set_umamba_command(CLI::App* com, mamba::Configuration& config) CLI::App* remove_subcom = com->add_subcommand("remove", "Remove packages from active environment"); set_remove_command(remove_subcom, config); + // `uninstall` is an alias for `remove` + CLI::App* uninstall_subcom = com->add_subcommand( + "uninstall", + "Remove packages from active environment" + ); + set_remove_command(uninstall_subcom, config); + CLI::App* list_subcom = com->add_subcommand("list", "List packages in active environment"); set_list_command(list_subcom, config); diff --git a/micromamba/tests/test_remove.py b/micromamba/tests/test_remove.py index fe710d5d50..5222b24308 100644 --- a/micromamba/tests/test_remove.py +++ b/micromamba/tests/test_remove.py @@ -261,3 +261,43 @@ def test_remove_config_target_prefix( else: res = helpers.remove(*cmd, "--print-config-only") remove_config_common_assertions(res, root_prefix=r, target_prefix=p) + + +def test_uninstall(tmp_home, tmp_root_prefix, tmp_xtensor_env, tmp_env_name): + # Install xtensor and then uninstall xtensor the first time with the `remove` + # subcommand and a second time with the `uninstall` subcommand and check that + # their outputs are the same and that the environment is in the same state + + # Check that the environment does not contain any packages + res_list = helpers.umamba_list("-n", tmp_env_name, "--json") + assert len(res_list) == 0 + + # Install xtensor + helpers.install("xtensor", "-n", tmp_env_name, no_dry_run=True) + + # Remove xtensor + res_remove = helpers.remove("xtensor", "-n", tmp_env_name, "--json") + assert res_remove["success"] + assert len(res_remove["actions"]["UNLINK"]) == 2 + assert res_remove["actions"]["UNLINK"][0]["name"] == "xtensor" + assert res_remove["actions"]["UNLINK"][1]["name"] == "xtl" + assert res_remove["actions"]["PREFIX"] == str(tmp_xtensor_env) + + # Check that the environment does not contain any packages + res_list = helpers.umamba_list("-n", tmp_env_name, "--json") + assert len(res_list) == 0 + + # Reinstall xtensor + helpers.install("xtensor", "-n", tmp_env_name, no_dry_run=True) + + # Uninstall xtensor + res_uninstall = helpers.uninstall("xtensor", "-n", tmp_env_name, "--json") + assert res_uninstall["success"] + assert len(res_uninstall["actions"]["UNLINK"]) == 2 + assert res_uninstall["actions"]["UNLINK"][0]["name"] == "xtensor" + assert res_uninstall["actions"]["UNLINK"][1]["name"] == "xtl" + assert res_uninstall["actions"]["PREFIX"] == str(tmp_xtensor_env) + + # Check that the environment does not contain any packages + res_list = helpers.umamba_list("-n", tmp_env_name, "--json") + assert len(res_list) == 0