fix(postinstall): add venv creation fallback for Debian/Ubuntu#2
Open
lixiao888 wants to merge 1 commit into
Open
fix(postinstall): add venv creation fallback for Debian/Ubuntu#2lixiao888 wants to merge 1 commit into
lixiao888 wants to merge 1 commit into
Conversation
On Debian/Ubuntu systems, python3-venv is not installed by default, causing 'python3 -m venv' to fail due to missing ensurepip module. This makes 'npm install -g @konbakuyomu/smart-search@latest' fail with: 'ensurepip is not available'. Add a three-strategy fallback chain: 1. python3 -m venv (original, works when python3-venv is installed) 2. virtualenv via pip --user (bundles pip independently) 3. venv --without-pip + get-pip.py bootstrap (no ensurepip needed) Fixes the installation failure on Debian/Ubuntu without python3-venv.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
npm install -g @konbakuyomu/smart-search@latestfails on Debian/Ubuntu systems with:Root cause: The
postinstall.jsscript usespython3 -m venvwhich requires theensurepipmodule. On Debian/Ubuntu,python3-venvis not installed by default, soensurepipis missing.Fix
Add a three-strategy fallback chain for venv creation:
python3 -m venv— original behavior, works whenpython3-venvis installedvirtualenv— install viapip install --user virtualenvif missing, then use it (bundles pip independently, noensurepipneeded)venv --without-pip+get-pip.py— create venv without pip, then bootstrap pip by downloadingget-pip.pyfrombootstrap.pypa.ioEach strategy is tried in order; on failure, the partial venv is cleaned up before trying the next. If all strategies fail, a clear error message directs the user to install
python3-venv.Testing
Verified on a Debian system without
python3-venv:ensurepipmissing)virtualenvnot installed)venv --without-pip+get-pip.pycreates a working venv with pipChanges
npm/scripts/postinstall.js: Extract venv creation intocreateVenv()with three fallback strategies; wrap main logic in asyncmain()to supportget-pip.pydownload; improve error messages for Debian/Ubuntu users.