diff --git a/install-nightly.sh b/install-nightly.sh index c12883c..c1b4e1a 100755 --- a/install-nightly.sh +++ b/install-nightly.sh @@ -256,7 +256,11 @@ info "🔧 Setting up Python virtual environment …" VENV_DIR="${INSTALL_DIR}/.venv" REQUIREMENTS="${INSTALL_DIR}/requirements.txt" -if [ ! -f "$VENV_DIR/bin/python3" ]; then +# A venv is usable only if python3 AND pip both work. Ubuntu's `python3 -m venv` +# without the python3-venv package leaves a venv with python3 but no pip — detect +# that and recreate, so a broken venv never survives a restart. +if [ ! -f "$VENV_DIR/bin/python3" ] || ! "$VENV_DIR/bin/python3" -m pip --version >/dev/null 2>&1; then + rm -rf "$VENV_DIR" if command -v uv >/dev/null 2>&1; then uv venv --seed "$VENV_DIR" && uv pip install -r "$REQUIREMENTS" \ && info "✔ Python venv ready (uv)" \ diff --git a/install.sh b/install.sh index 60b6f83..596a436 100755 --- a/install.sh +++ b/install.sh @@ -261,7 +261,11 @@ info "🔧 Setting up Python virtual environment …" VENV_DIR="${INSTALL_DIR}/.venv" REQUIREMENTS="${INSTALL_DIR}/requirements.txt" -if [ ! -f "$VENV_DIR/bin/python3" ]; then +# A venv is usable only if python3 AND pip both work. Ubuntu's `python3 -m venv` +# without the python3-venv package leaves a venv with python3 but no pip — detect +# that and recreate, so a broken venv never survives a restart. +if [ ! -f "$VENV_DIR/bin/python3" ] || ! "$VENV_DIR/bin/python3" -m pip --version >/dev/null 2>&1; then + rm -rf "$VENV_DIR" if command -v uv >/dev/null 2>&1; then uv venv --seed "$VENV_DIR" && uv pip install -r "$REQUIREMENTS" \ && info "✔ Python venv ready (uv)" \ diff --git a/run-docker.sh b/run-docker.sh index af33a4a..5dc04f8 100644 --- a/run-docker.sh +++ b/run-docker.sh @@ -11,7 +11,11 @@ cd "$(dirname "$0")" VENV_DIR=".venv" REQUIREMENTS="requirements.txt" -if [ ! -f "$VENV_DIR/bin/python3" ] && [ -f "$REQUIREMENTS" ]; then +# A venv is usable only if python3 AND pip both work. Ubuntu's `python3 -m venv` +# without the python3-venv package leaves a venv with python3 but no pip — detect +# that and recreate, so a broken venv never survives a restart. +if [ -f "$REQUIREMENTS" ] && { [ ! -f "$VENV_DIR/bin/python3" ] || ! "$VENV_DIR/bin/python3" -m pip --version >/dev/null 2>&1; }; then + rm -rf "$VENV_DIR" if command -v uv >/dev/null 2>&1; then echo "[run-docker.sh] Setting up Python venv with uv …" uv venv --seed "$VENV_DIR" && uv pip install -r "$REQUIREMENTS" \ diff --git a/run.sh b/run.sh index 7a78469..70a9ada 100755 --- a/run.sh +++ b/run.sh @@ -50,7 +50,11 @@ fi VENV_DIR=".venv" REQUIREMENTS="requirements.txt" -if [ ! -f "$VENV_DIR/bin/python3" ]; then +# A venv is usable only if python3 AND pip both work. Ubuntu's `python3 -m venv` +# without the python3-venv package leaves a venv with python3 but no pip — detect +# that and recreate, so a broken venv never survives a restart. +if [ ! -f "$VENV_DIR/bin/python3" ] || ! "$VENV_DIR/bin/python3" -m pip --version >/dev/null 2>&1; then + rm -rf "$VENV_DIR" if command -v uv >/dev/null 2>&1; then echo "[run.sh] Setting up Python venv with uv …" uv venv --seed "$VENV_DIR" && uv pip install -r "$REQUIREMENTS" \