Skip to content

Commit

Permalink
Refuse to uninstall federated extensions.
Browse files Browse the repository at this point in the history
Since we did not install the federated extension, we should not be uninstalling it and deleting files from other packages and installation systems.

Fixes #9230

See more discussion at #9231.
  • Loading branch information
jasongrout committed Oct 27, 2020
1 parent f7cb7b5 commit e6ed7a5
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions jupyterlab/commands.py
Expand Up @@ -816,24 +816,6 @@ def uninstall_extension(self, name):
info = self.info
logger = self.logger

# Handle federated extensions first
if name in info['federated_exts']:
data = info['federated_exts'].pop(name)
target = data['ext_path']
logger.info("Removing: %s" % target)
if os.path.isdir(target) and not os.path.islink(target):
shutil.rmtree(target)
else:
os.remove(target)
# Remove empty parent dir if necessary
if '/' in data['name']:
files = os.listdir(os.path.dirname(target))
if not len(files):
target = os.path.dirname(target)
if os.path.isdir(target) and not os.path.islink(target):
shutil.rmtree(target)
return False

# Allow for uninstalled core extensions.
if name in info['core_extensions']:
config = self._read_build_config()
Expand Down Expand Up @@ -862,6 +844,9 @@ def uninstall_extension(self, name):
self._write_build_config(config)
return True

if name in info['federated_exts']:
logger.warn('%s was installed with a package manager. Use the same package manager to uninstall this extension.' % name)

logger.warn('No labextension named "%s" installed' % name)
return False

Expand Down

0 comments on commit e6ed7a5

Please sign in to comment.