mirror of
https://github.com/leonvanzyl/autocoder.git
synced 2026-01-30 06:12:06 +00:00
fix: handle cross-platform venv compatibility in WSL
Changes: - start_ui.sh, start.sh: Check for venv/bin/activate instead of just venv/ directory to detect Windows venvs in Linux/WSL - Auto-recreate venv when incompatible platform structure detected - Add error handling for venv removal, creation, and activation failures - Provide actionable error messages with distro-specific instructions - start_ui.bat: Check for venv\Scripts\activate.bat for consistency with start.bat pattern Fixes issue where users cloning repo in WSL would encounter: - "venv/bin/activate: No such file or directory" - "No module named pip" errors Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
29
start.sh
29
start.sh
@@ -58,14 +58,39 @@ fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Check if venv exists, create if not
|
||||
if [ ! -d "venv" ]; then
|
||||
# Check if venv exists with correct structure for this platform
|
||||
# Windows venvs have Scripts/, Linux/macOS have bin/
|
||||
if [ ! -f "venv/bin/activate" ]; then
|
||||
if [ -d "venv" ]; then
|
||||
echo "[INFO] Detected incompatible virtual environment (possibly created on Windows)"
|
||||
echo "[INFO] Recreating virtual environment for this platform..."
|
||||
rm -rf venv
|
||||
if [ -d "venv" ]; then
|
||||
echo "[ERROR] Failed to remove existing virtual environment"
|
||||
echo "Please manually delete the 'venv' directory and try again:"
|
||||
echo " rm -rf venv"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Creating virtual environment..."
|
||||
fi
|
||||
python3 -m venv venv
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[ERROR] Failed to create virtual environment"
|
||||
echo "Please ensure the venv module is installed:"
|
||||
echo " Ubuntu/Debian: sudo apt install python3-venv"
|
||||
echo " Or try: python3 -m ensurepip"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Activate the virtual environment
|
||||
source venv/bin/activate
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[ERROR] Failed to activate virtual environment"
|
||||
echo "The venv may be corrupted. Try: rm -rf venv && ./start.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Install dependencies
|
||||
echo "Installing dependencies..."
|
||||
|
||||
@@ -18,8 +18,8 @@ if %ERRORLEVEL% neq 0 (
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM Check if venv exists, create if not
|
||||
if not exist "venv" (
|
||||
REM Check if venv exists with correct activation script
|
||||
if not exist "venv\Scripts\activate.bat" (
|
||||
echo Creating virtual environment...
|
||||
python -m venv venv
|
||||
)
|
||||
|
||||
29
start_ui.sh
29
start_ui.sh
@@ -21,14 +21,39 @@ else
|
||||
PYTHON_CMD="python3"
|
||||
fi
|
||||
|
||||
# Check if venv exists, create if not
|
||||
if [ ! -d "venv" ]; then
|
||||
# Check if venv exists with correct structure for this platform
|
||||
# Windows venvs have Scripts/, Linux/macOS have bin/
|
||||
if [ ! -f "venv/bin/activate" ]; then
|
||||
if [ -d "venv" ]; then
|
||||
echo "[INFO] Detected incompatible virtual environment (possibly created on Windows)"
|
||||
echo "[INFO] Recreating virtual environment for this platform..."
|
||||
rm -rf venv
|
||||
if [ -d "venv" ]; then
|
||||
echo "[ERROR] Failed to remove existing virtual environment"
|
||||
echo "Please manually delete the 'venv' directory and try again:"
|
||||
echo " rm -rf venv"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Creating virtual environment..."
|
||||
fi
|
||||
$PYTHON_CMD -m venv venv
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[ERROR] Failed to create virtual environment"
|
||||
echo "Please ensure the venv module is installed:"
|
||||
echo " Ubuntu/Debian: sudo apt install python3-venv"
|
||||
echo " Or try: $PYTHON_CMD -m ensurepip"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Activate the virtual environment
|
||||
source venv/bin/activate
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[ERROR] Failed to activate virtual environment"
|
||||
echo "The venv may be corrupted. Try: rm -rf venv && ./start_ui.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Install dependencies
|
||||
echo "Installing dependencies..."
|
||||
|
||||
Reference in New Issue
Block a user