fix(install): 🐛 Improve UV installation process and error handling

* Enhanced the installation script for `uv` by:
  * Adding checks for existing installations.
  * Improving error messages for PowerShell script execution.
  * Ensuring `uv` is correctly added to the PATH for the current session.
* Updated the installation confirmation messages for clarity.
This commit is contained in:
Andy
2025-07-25 22:40:46 +00:00
parent 1b9fbe3401
commit c81b7f192e

View File

@@ -1,47 +1,61 @@
@echo off @echo off
echo Installing unshackle dependencies... setlocal EnableExtensions EnableDelayedExpansion
echo.
echo === Unshackle setup (Windows) ===
echo. echo.
REM Check if UV is already installed where uv >nul 2>&1
uv --version >nul 2>&1
if %errorlevel% equ 0 ( if %errorlevel% equ 0 (
echo UV is already installed. echo [OK] uv is already installed.
goto install_deps goto install_deps
) )
echo UV not found. Installing UV... echo [..] uv not found. Installing...
echo.
REM Install UV using the official installer powershell -NoProfile -ExecutionPolicy Bypass -Command "irm https://astral.sh/uv/install.ps1 | iex"
powershell -Command "irm https://astral.sh/uv/install.ps1 | iex"
if %errorlevel% neq 0 ( if %errorlevel% neq 0 (
echo Failed to install UV. Please install UV manually from https://docs.astral.sh/uv/getting-started/installation/ echo [ERR] Failed to install uv.
echo PowerShell may be blocking scripts. Try:
echo Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
echo or install manually: https://docs.astral.sh/uv/getting-started/installation/
pause pause
exit /b 1 exit /b 1
) )
REM Add UV to PATH for current session set "UV_BIN="
set "PATH=%USERPROFILE%\.cargo\bin;%PATH%" for %%D in ("%USERPROFILE%\.local\bin" "%LOCALAPPDATA%\Programs\uv\bin" "%USERPROFILE%\.cargo\bin") do (
if exist "%%~fD\uv.exe" set "UV_BIN=%%~fD"
)
echo UV installed successfully. if not defined UV_BIN (
echo. echo [WARN] Could not locate uv.exe. You may need to reopen your terminal.
) else (
set "PATH=%UV_BIN%;%PATH%"
)
:: Verify
uv --version >nul 2>&1
if %errorlevel% neq 0 (
echo [ERR] uv still not reachable in this shell. Open a new terminal and re-run this script.
pause
exit /b 1
)
echo [OK] uv installed and reachable.
:install_deps :install_deps
echo Installing project dependencies in editable mode with dev dependencies...
echo. echo.
REM Install the project in editable mode with dev dependencies
uv sync uv sync
if %errorlevel% neq 0 ( if %errorlevel% neq 0 (
echo Failed to install dependencies. Please check the error messages above. echo [ERR] Dependency install failed. See errors above.
pause pause
exit /b 1 exit /b 1
) )
echo. echo.
echo Installation completed successfully! echo Installation completed successfully!
echo. echo Try:
echo You can now run unshackle using:
echo uv run unshackle --help echo uv run unshackle --help
echo. echo.
pause pause
endlocal