Merge pull request #3 from alexpolo1/fix/install-conda-user-scope
fix(install): install conda without admin + verify git download
This commit is contained in:
36
install.bat
36
install.bat
@@ -59,13 +59,25 @@ echo This is a one-time setup (~100 MB). Please wait.
|
||||
echo.
|
||||
|
||||
:: --- Method 1: winget (cleanest; available on Win10 1709+ and all Win11) ---
|
||||
:: --scope user is critical: without it winget defaults to a machine-wide
|
||||
:: install (lands in %ProgramData%) which REQUIRES admin. A normal double-click
|
||||
:: (no elevation) then fails silently and conda never installs. --scope user
|
||||
:: installs to %USERPROFILE%\miniforge3 with no admin needed — which is also one
|
||||
:: of the locations :rescan_conda searches.
|
||||
winget --version >nul 2>&1
|
||||
if %errorlevel% equ 0 (
|
||||
echo Installing via winget...
|
||||
winget install --id CondaForge.Miniforge3 --exact --silent ^
|
||||
winget install --id CondaForge.Miniforge3 --exact --silent --scope user ^
|
||||
--accept-package-agreements --accept-source-agreements
|
||||
if !errorlevel! equ 0 goto :rescan_conda
|
||||
echo winget install failed — falling back to direct download.
|
||||
:: winget returns non-zero when the package is already installed, so don't
|
||||
:: trust the exit code — rescan for conda and only fall through to the
|
||||
:: direct download if it's genuinely still missing.
|
||||
for %%C in (
|
||||
"%LOCALAPPDATA%\miniforge3\Scripts\conda.exe"
|
||||
"%USERPROFILE%\miniforge3\Scripts\conda.exe"
|
||||
"%ProgramData%\miniforge3\Scripts\conda.exe"
|
||||
) do if exist %%C goto :rescan_conda
|
||||
echo winget did not produce a usable conda — falling back to direct download.
|
||||
echo.
|
||||
)
|
||||
|
||||
@@ -78,6 +90,7 @@ if %errorlevel% equ 0 (
|
||||
set "MF_INSTALLER=%TEMP%\Miniforge3-installer.exe"
|
||||
set "MF_URL=https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Windows-x86_64.exe"
|
||||
|
||||
del /q "%MF_INSTALLER%" >nul 2>&1
|
||||
echo Downloading Miniforge3...
|
||||
curl -Lk --progress-bar "%MF_URL%" -o "%MF_INSTALLER%" 2>&1
|
||||
if %errorlevel% neq 0 (
|
||||
@@ -95,6 +108,23 @@ if not exist "%MF_INSTALLER%" (
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: Verify the download is a real installer, not a truncated file or an HTML
|
||||
:: error page served with a 200. The Miniforge installer is ~78 MB; anything
|
||||
:: under 40 MB means the download failed even though a file exists.
|
||||
for %%A in ("%MF_INSTALLER%") do set "MF_SIZE=%%~zA"
|
||||
if not defined MF_SIZE set "MF_SIZE=0"
|
||||
if %MF_SIZE% LSS 41943040 (
|
||||
echo.
|
||||
echo ERROR: Downloaded Miniforge3 installer is only %MF_SIZE% bytes — the
|
||||
echo download was incomplete or blocked. Check your internet/proxy, or install
|
||||
echo manually then re-run install.bat:
|
||||
echo https://github.com/conda-forge/miniforge/releases/latest
|
||||
echo.
|
||||
del /q "%MF_INSTALLER%" >nul 2>&1
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Installing Miniforge3 (this takes ~1 minute)...
|
||||
start /wait "" "%MF_INSTALLER%" /S /InstallationType=JustMe /AddToPath=0 /RegisterPython=0 /NoShortcuts=1 /NoRegistry=1
|
||||
if %errorlevel% neq 0 (
|
||||
|
||||
Reference in New Issue
Block a user