Skip to content

Commit

Permalink
remove SYMLINK_CONDA
Browse files Browse the repository at this point in the history
  • Loading branch information
kalefranz committed Nov 11, 2016
1 parent e895b79 commit ed57493
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
7 changes: 5 additions & 2 deletions conda/cli/main_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,11 @@ def execute(args, parser):

else:
specs = specs_from_args(args.package_names)
if (not args.force and context.conda_in_root and plan.is_root_prefix(prefix) and
names_in_specs(ROOT_NO_RM, specs)):
# import pdb; pdb.set_trace()
if (context.conda_in_root
and plan.is_root_prefix(prefix)
and names_in_specs(ROOT_NO_RM, specs)
and not args.force):
raise CondaEnvironmentError('cannot remove %s from root environment' %
', '.join(ROOT_NO_RM))
actions = plan.remove_actions(prefix, specs, index=index,
Expand Down
3 changes: 2 additions & 1 deletion conda/instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def UNLINK_CMD(state, arg):


def SYMLINK_CONDA_CMD(state, arg):
symlink_conda(state['prefix'], arg)
log.debug("No longer symlinking conda. Passing for prefix %s", state['prefix'])
# symlink_conda(state['prefix'], arg)

# Map instruction to command (a python function)
commands = {
Expand Down
2 changes: 1 addition & 1 deletion conda/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ def remove_actions(prefix, specs, index, force=False, pinned=True):
if pinned and any(r.match(ms, old_dist.to_filename()) for ms in pinned_specs):
msg = "Cannot remove %s because it is pinned. Use --no-pin to override."
raise CondaRuntimeError(msg % old_dist.to_filename())
if context.conda_in_root and name == 'conda' and name not in nlinked:
if context.conda_in_root and name == 'conda' and name not in nlinked and not context.force:
if any(s.split(' ', 1)[0] == 'conda' for s in specs):
raise RemoveError("'conda' cannot be removed from the root environment")
else:
Expand Down
23 changes: 22 additions & 1 deletion tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from conda.connection import LocalFSAdapter
from conda.core.index import create_cache_dir
from conda.core.linked_data import linked as install_linked, linked_data, linked_data_
from conda.exceptions import CondaHTTPError, DryRunExit, conda_exception_handler
from conda.exceptions import CondaHTTPError, DryRunExit, conda_exception_handler, RemoveError
from conda.utils import on_win
from contextlib import contextmanager
from datetime import datetime
Expand Down Expand Up @@ -861,3 +861,24 @@ def test_install_mkdir(self):

finally:
rmtree(prefix, ignore_errors=True)

def test_force_remove(self):
prefix = make_temp_prefix("_" + str(uuid4())[:7])
with make_temp_env(prefix=prefix):
stdout, stderr = run_command(Commands.INSTALL, prefix, "conda")
assert_package_is_installed(prefix, "conda-")
assert_package_is_installed(prefix, "pycosat-")

self.assertRaises(RemoveError, run_command, Commands.REMOVE, prefix, 'conda')
assert_package_is_installed(prefix, "conda-")
assert_package_is_installed(prefix, "pycosat-")

stdout, stderr = run_command(Commands.REMOVE, prefix, "conda", "--force")

# assert conda is no longer in conda list
stdout, stderr = run_command(Commands.LIST, prefix)
stdout_lines = stdout.split('\n')
assert not any([line.startswith("conda ") for line in stdout_lines])

assert package_is_installed(prefix, "pycosat-")

0 comments on commit ed57493

Please sign in to comment.