From 1f8f7fc163ff5fc3f43b73dd377e98675b730690 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Thu, 2 Apr 2026 00:26:28 +0200 Subject: [PATCH] Unable to install plugins through web UI using custom registry and/or Python wheel files. Fixes #11460 --- src/backend/InvenTree/plugin/installer.py | 37 ++++++++++++++--------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/backend/InvenTree/plugin/installer.py b/src/backend/InvenTree/plugin/installer.py index b1fb2de03f..1f6b3c86ee 100644 --- a/src/backend/InvenTree/plugin/installer.py +++ b/src/backend/InvenTree/plugin/installer.py @@ -245,9 +245,7 @@ def install_plugin(url=None, packagename=None, user=None, version=None): logger.info('install_plugin: %s, %s', url, packagename) # build up the command - install_name = ['install', '-U', '--disable-pip-version-check'] - - full_pkg = '' + full_pkg = None if url: # use custom registration / VCS @@ -255,27 +253,34 @@ def install_plugin(url=None, packagename=None, user=None, version=None): identifier in url for identifier in ['git+https', 'hg+https', 'svn+svn'] ]: # using a VCS provider - full_pkg = f'{packagename}@{url}' if packagename else url - elif url: - install_name.append('-i') - full_pkg = url - elif packagename: - full_pkg = packagename + full_pkg = [f'{packagename}@{url}' if packagename else url] + elif url and packagename: + full_pkg = [packagename, '-i', url] + else: + full_pkg = ['-i', url] elif packagename: # use pypi - full_pkg = packagename + full_pkg = [packagename] if version: - full_pkg = f'{full_pkg}=={version}' + full_pkg = [f'{packagename}=={version}'] - install_name.append(full_pkg) + if not full_pkg: + raise ValidationError( + _('No package name or URL could be generated with the inputs provided') + ) ret = {} # Execute installation via pip try: - result = pip_command(*install_name) + result = pip_command(*[ + 'install', + '-U', + '--disable-pip-version-check', + *full_pkg, + ]) ret['result'] = ret['success'] = _('Installed plugin successfully') ret['output'] = str(result, 'utf-8') @@ -292,7 +297,11 @@ def install_plugin(url=None, packagename=None, user=None, version=None): if version := ret.get('version'): # Save plugin to plugins file - update_plugins_file(packagename, full_package=full_pkg, version=version) + update_plugins_file( + packagename, + full_package=' '.join(full_pkg) if isinstance(full_pkg, list) else None, + version=version, + ) # Reload the plugin registry, to discover the new plugin from plugin.registry import registry