Skip to content

Commit

Permalink
Merge pull request conda#9582 from soapy1/delete-empty-env
Browse files Browse the repository at this point in the history
Delete empty env
  • Loading branch information
Sophia Castellarin authored Jan 9, 2020
2 parents 568a948 + afe2728 commit 4636829
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions conda/cli/main_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from ..exceptions import CondaEnvironmentError, CondaValueError
from ..gateways.disk.delete import rm_rf, path_is_clean
from ..models.match_spec import MatchSpec
from ..exceptions import PackagesNotFoundError

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -65,8 +66,10 @@ def execute(args, parser):
neutered_specs={},
)
txn = UnlinkLinkTransaction(stp)
handle_txn(txn, prefix, args, False, True)

try:
handle_txn(txn, prefix, args, False, True)
except PackagesNotFoundError:
print("No packages found in %s. Continuing environment removal" % prefix)
rm_rf(prefix, clean_empty_parents=True)
unregister_env(prefix)

Expand Down
5 changes: 5 additions & 0 deletions tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -2834,6 +2834,11 @@ def test_neutering_of_historic_specs(self):
# If this command runs successfully (does not raise), then all is well.
stdout, stderr, _ = run_command(Commands.INSTALL, prefix, "imagesize")

@pytest.mark.integration
def test_remove_empty_env(self):
with make_temp_env() as prefix:
run_command(Commands.CREATE, prefix)
run_command(Commands.REMOVE, prefix, '--all')

@pytest.mark.skipif(True, reason="get the rest of Solve API worked out first")
@pytest.mark.integration
Expand Down

0 comments on commit 4636829

Please sign in to comment.