Skip to content

Commit

Permalink
fix: using scoop with proxies requiring auth not working
Browse files Browse the repository at this point in the history
  • Loading branch information
sebthom committed Feb 9, 2025
1 parent 17918ba commit 75d2a6a
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions scoop-portable.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
:: =====
:: This is a self-contained Windows batch file to install and launch a portable scoop (https://github.com/lukesampson/scoop) environment.


:: ############################################################################
:: act as wrapper for shims\scoop.cmd if this batch file is located at [scoop_install_root]\.portable\scoop.cmd
:: ############################################################################
Expand Down Expand Up @@ -191,13 +190,15 @@ goto :eof
call :log_TASK Downloading scoop installer
:: ==========================================================================
:: https://github.com/lukesampson/scoop/wiki/Using-Scoop-behind-a-proxy
if not "%SCOOP_PROXY%" == "" (
if defined SCOOP_PROXY (
call :log_TASK Downloading scoop installer using proxy [%SCOOP_PROXY%]
set "scoopProxy=[net.webrequest]::defaultwebproxy = new-object net.webproxy 'http://%SCOOP_PROXY%';"
if "%SCOOP_PROXY_USE_WINDOWS_CREDENTIALS%" == "true" (
set "scoopProxy=!scoopProxy!; [net.webrequest]::defaultwebproxy.credentials = [net.credentialcache]::defaultcredentials;"
) else if not "%SCOOP_PROXY_USER%" == "" (
set "scoopProxy=!scoopProxy!; [net.webrequest]::defaultwebproxy.credentials = new-object net.networkcredential '%SCOOP_PROXY_USER%', '%SCOOP_PROXY_PASSWORD%';"
) else (
if defined SCOOP_PROXY_USER (
set "scoopProxy=!scoopProxy!; [net.webrequest]::defaultwebproxy.credentials = new-object net.networkcredential '%SCOOP_PROXY_USER%', '%SCOOP_PROXY_PASSWORD%';"
)
)
)

Expand All @@ -222,11 +223,20 @@ goto :eof

echo %USERDOMAIN%\%USERNAME%>"%SCOOP%\.portable\last.user"

if not "%SCOOP_PROXY%" == "" (
call "%SCOOP%\.portable\scoop.cmd" config proxy %SCOOP_PROXY% || exit /B 1
:: https://github.com/ScoopInstaller/Scoop/wiki/Using-Scoop-behind-a-proxy
if defined SCOOP_PROXY (
if "%SCOOP_PROXY_USE_WINDOWS_CREDENTIALS%" (
call "%SCOOP%\.portable\scoop.cmd" config proxy currentuser@%SCOOP_PROXY% || exit /B 1
) else (
if defined SCOOP_PROXY_USER (
call "%SCOOP%\.portable\scoop.cmd" config proxy %SCOOP_PROXY_USER%:%SCOOP_PROXY_USER%@%SCOOP_PROXY% || exit /B 1
) else (
call "%SCOOP%\.portable\scoop.cmd" config proxy %SCOOP_PROXY% || exit /B 1
)
)
)

if not "%SCOOP_BUCKETS%" == "" (
if defined SCOOP_BUCKETS (
REM install git if not present - required for adding buckets
where /Q git.exe
if errorlevel 1 (
Expand All @@ -248,7 +258,7 @@ goto :eof
)
)

if not "%SCOOP_PACKAGES%" == "" (
if defined SCOOP_PACKAGES (
call :log_TASK Installing packages [%SCOOP_PACKAGES%]
setlocal
for %%p in (%SCOOP_PACKAGES%) do (
Expand Down

0 comments on commit 75d2a6a

Please sign in to comment.