vegardit / scoop-portable

Self-contained Windows batch file that installs/loads a portable scoop (https://scoop.sh) environment.
Apache License 2.0
8 stars 3 forks source link

'scoop update' doesn't work at all #5

Closed gloomy-lemon-debatable closed 2 months ago

gloomy-lemon-debatable commented 5 months ago

After running scoop-portable.cmd, type scoop update to get the following output:

C:\>scoop update git
The syntax of the command is incorrect.
sebthom commented 5 months ago

Hmm, I am using it on Windows 10 and it works fine for me:

> scoop update 7zip
7zip: 24.05 -> 24.06
Updating one outdated app:
Updating '7zip' (24.05 -> 24.06)
Downloading new version
7z2406-x64.msi (1,9 MB) [========================================] 100%
Checking hash of 7z2406-x64.msi ... ok.
Uninstalling '7zip' (24.05)
Removing shim '7z.shim'.
Removing shim '7z.exe'.
Removing shim '7zFM.shim'.
Removing shim '7zFM.exe'.
Removing shim '7zG.shim'.
Removing shim '7zG.exe'.
Unlinking E:\scoop-portable\apps\7zip\current
Installing '7zip' (24.06) [64bit] from 'main' bucket
Loading 7z2406-x64.msi from cache
Extracting 7z2406-x64.msi ... done.
Linking E:\scoop-portable\apps\7zip\current => E:\scoop-portable\apps\7zip\24.06
Creating shim for '7z'.
Adding E:\scoop-portable\shims to your path.
Creating shim for '7zFM'.
Making E:\scoop-portable\shims\7zfm.exe a GUI binary.
Creating shim for '7zG'.
Making E:\scoop-portable\shims\7zg.exe a GUI binary.
Persisting Codecs
Persisting Formats
Running post_install script...
'7zip' (24.06) was installed successfully!
Notes
-----
Add 7-Zip as a context menu option by running: "E:\scoop-portable\apps\7zip\current\install-context.reg"
[13:12:11,10] Restoring PATH variable...

SUCCESS: Specified value was saved.
gloomy-lemon-debatable commented 5 months ago

I apologise for the lack of explanation, I have left out a lot of things as I have got the same results when I did it in Win10 and in Win11. I hope this would be helpful, but please feel free to let me know if there's anything else I can provide. I've included the full text of the input and the devices I tried:

C:\test\scoop>scoop update git The syntax of the command is incorrect.

C:\test\scoop>



- Environment1
Edition:    Windows 10 Pro
Version:    22H2
OS build:   19045.4412
Experience: Windows Feature Experience Pack 1000.19056.1000.0

- Environment2
Edition:    Windows 11 Home
Version:    23H2
OS build:   22631.3593
Experience: Windows Feature Experience Pack 1000.22700.1003.0
sebthom commented 5 months ago

Can you please try this:

  1. load the scoop portable environment via scoop-portable.cmd in a command window
  2. remove the line @echo off in the file C:\test\scoop\.portable\scoop.cmd
  3. rerun scoop update git in the same command window from step 1
  4. Check the output to see which command failed.
gloomy-lemon-debatable commented 5 months ago

All right. Here is the result of the execution:

C:\test\scoop>scoop update git

C:\test\scoop>rem @echo off

C:\test\scoop>call :ends_with "C:\test\scoop\.portable\scoop.cmd" ".portable\scoop.cmd"   && (
call :intercept_scoop_command update git
 goto :eof
)

C:\test\scoop>echo C:\test\scoop\.portable\scoop.cmd  | findstr /E /L ".portable\scoop.cmd"  1>NUL

C:\test\scoop>goto :eof

C:\test\scoop>call :has_arg --help update git   && (
call "C:\test\scoop\shims\scoop.cmd" update git
 goto :eof
)

C:\test\scoop>setlocal

C:\test\scoop>set "search_for=--help"   & shift /1

C:\test\scoop>set empty_args=0

C:\test\scoop>REM not using "for %a in (--help update git)" which automatically expands wildcard arguments

C:\test\scoop>set "arg=update"

C:\test\scoop>if "update" == "--help" exit /B 0

C:\test\scoop>if "update" == "" (
REM stop looping if more than 6 empty args in a row were found. this is a workaround for the fact that one cannot
 REM distinguish between an empty "" argument and the end of the argument list
 if 0 == 6 (exit /B 1 )  else (set /a empty_args+=1 )
)  else (set empty_args=0 )

C:\test\scoop>shift /1

C:\test\scoop>goto :has_arg___CHECK_NEXT_ARG

C:\test\scoop>set "arg=git"

C:\test\scoop>if "git" == "--help" exit /B 0

C:\test\scoop>if "git" == "" (
REM stop looping if more than 6 empty args in a row were found. this is a workaround for the fact that one cannot
 REM distinguish between an empty "" argument and the end of the argument list
 if 0 == 6 (exit /B 1 )  else (set /a empty_args+=1 )
)  else (set empty_args=0 )

C:\test\scoop>shift /1

C:\test\scoop>goto :has_arg___CHECK_NEXT_ARG

C:\test\scoop>set "arg="

C:\test\scoop>if "" == "--help" exit /B 0

C:\test\scoop>if "" == "" (
REM stop looping if more than 6 empty args in a row were found. this is a workaround for the fact that one cannot
 REM distinguish between an empty "" argument and the end of the argument list
 if 0 == 6 (exit /B 1 )  else (set /a empty_args+=1 )
)  else (set empty_args=0 )

C:\test\scoop>shift /1

C:\test\scoop>goto :has_arg___CHECK_NEXT_ARG

C:\test\scoop>set "arg="

C:\test\scoop>if "" == "--help" exit /B 0

C:\test\scoop>if "" == "" (
REM stop looping if more than 6 empty args in a row were found. this is a workaround for the fact that one cannot
 REM distinguish between an empty "" argument and the end of the argument list
 if 1 == 6 (exit /B 1 )  else (set /a empty_args+=1 )
)  else (set empty_args=0 )

C:\test\scoop>shift /1

C:\test\scoop>goto :has_arg___CHECK_NEXT_ARG

C:\test\scoop>set "arg="

C:\test\scoop>if "" == "--help" exit /B 0

C:\test\scoop>if "" == "" (
REM stop looping if more than 6 empty args in a row were found. this is a workaround for the fact that one cannot
 REM distinguish between an empty "" argument and the end of the argument list
 if 2 == 6 (exit /B 1 )  else (set /a empty_args+=1 )
)  else (set empty_args=0 )

C:\test\scoop>shift /1

C:\test\scoop>goto :has_arg___CHECK_NEXT_ARG

C:\test\scoop>set "arg="

C:\test\scoop>if "" == "--help" exit /B 0

C:\test\scoop>if "" == "" (
REM stop looping if more than 6 empty args in a row were found. this is a workaround for the fact that one cannot
 REM distinguish between an empty "" argument and the end of the argument list
 if 3 == 6 (exit /B 1 )  else (set /a empty_args+=1 )
)  else (set empty_args=0 )

C:\test\scoop>shift /1

C:\test\scoop>goto :has_arg___CHECK_NEXT_ARG

C:\test\scoop>set "arg="

C:\test\scoop>if "" == "--help" exit /B 0

C:\test\scoop>if "" == "" (
REM stop looping if more than 6 empty args in a row were found. this is a workaround for the fact that one cannot
 REM distinguish between an empty "" argument and the end of the argument list
 if 4 == 6 (exit /B 1 )  else (set /a empty_args+=1 )
)  else (set empty_args=0 )

C:\test\scoop>shift /1

C:\test\scoop>goto :has_arg___CHECK_NEXT_ARG

C:\test\scoop>set "arg="

C:\test\scoop>if "" == "--help" exit /B 0

C:\test\scoop>if "" == "" (
REM stop looping if more than 6 empty args in a row were found. this is a workaround for the fact that one cannot
 REM distinguish between an empty "" argument and the end of the argument list
 if 5 == 6 (exit /B 1 )  else (set /a empty_args+=1 )
)  else (set empty_args=0 )

C:\test\scoop>shift /1

C:\test\scoop>goto :has_arg___CHECK_NEXT_ARG

C:\test\scoop>set "arg="

C:\test\scoop>if "" == "--help" exit /B 0

C:\test\scoop>if "" == "" (
REM stop looping if more than 6 empty args in a row were found. this is a workaround for the fact that one cannot
 REM distinguish between an empty "" argument and the end of the argument list
 if 6 == 6 (exit /B 1 )  else (set /a empty_args+=1 )
)  else (set empty_args=0 )

C:\test\scoop>setlocal EnableDelayedExpansion

C:\test\scoop>set scoop_command=update

C:\test\scoop>if "update" == "update" (
call :get_2nd_positional_arg app_name update git
 if "!app_name!" == "" (set app_name=scoop )
 if !app_name! == scoop (
call :unpatch_scoop
 set "XDG_CONFIG_HOME=C:\test\scoop\.portable"
)
 call :getx_PATH PATH_BEFORE_UPDATE
 call "C:\test\scoop\shims\scoop.cmd" update git
 set rc=!errorlevel!
 if !app_name! == scoop (call :patch_scoop )  else if "!app_name!" == "*" (call :save_active_versions )  else (
REM /update git makes the first arg (the command) a flag so it is not treated as an app name
 call :get_positional_args apps /update git
 for %a in (!apps!) do call :save_active_version %a
)
 call :getx_PATH PATH_AFTER_UPDATE
 if not "!PATH_BEFORE_UPDATE!" == "!PATH_AFTER_UPDATE!" (
call :log_TASK Restoring PATH variable
 setx PATH  "!PATH_BEFORE_UPDATE!"
)
 exit /B !rc!
)
The syntax of the command is incorrect.

C:\test\scoop>..>

C:\test\scoop>
sebthom commented 5 months ago

hm not really helpful. Maybe there is something special about your PATH variable and the batch file fails to parse it, e.g. maybe it contains special characters. Could you post the value of %PATH% after you loaded scoop-portable?

gloomy-lemon-debatable commented 5 months ago
C:\test\scoop>echo %PATH%
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\WireGuard\;C:\test\scoop\shims;C:\Users\admin\AppData\Local\Microsoft\WindowsApps

I was curious about the C:\test\scoop\shims so I removed it and restarted, but I’m afraid that did not change the result.

sebthom commented 5 months ago

The PATH looks normal.

The error occurs in this section: https://github.com/vegardit/scoop-portable/blob/17918baf27a9a389e797e2a6d423c8d8a11a2b53/scoop-portable.cmd#L351-L382

Maybe you can add some echo statements to narrow it down.

stale[bot] commented 3 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.