Closed rashil2000 closed 1 year ago
What are the contents of the E:\Scoop Stuff\shims\clink.cmd
file? It intentionally intercepts every invocation of clink
, so the shim has the ability to mess things up if it has a bug.
Has your scoop directory always had a space in it, or was that a more recent change? The error message looks like something is mishandling quoted arguments.
Maybe there's a bug in the shim, or maybe there's a bug in the PowerShell version of scoop.
Whatever is happening seems to be unrelated to Clink. You'll have to do some investigation.
Interesting; maybe relevant: https://github.com/ScoopInstaller/Scoop/issues/5313
The contents of clink.cmd are as follows:
@rem E:\Scoop Stuff\apps\clink\current\clink.bat
@"E:\Scoop Stuff\apps\clink\current\clink.bat" %*
Scoop automatically creates shims based on the file extension. The code for .cmd|.bat
files lives here: https://github.com/ScoopInstaller/Scoop/blob/master/lib/core.ps1#L723-L736
The same .cmd file is invoked in both PowerShell and Command Prompt, so where could the difference be?
Interesting; maybe relevant: ScoopInstaller/Scoop#5313
This one seems unrelated (it was fixed in a PR: https://github.com/ScoopInstaller/Scoop/pull/5326)
@rashil2000 I took a closer look.
It used to work perfectly fine, but now when using this command in PowerShell, this error comes up:
I eventually tracked down what's happening (see further below).
I chose to make guesses/assumptions to try to fill in the blanks in the info that was provided, but I guessed wrong, which is why I couldn't reproduce the problem at first.
It does not show an error when ran through Command Prompt:
❯ clink installscripts "E:\Scoop Stuff\apps\clink-completions\0.4.1" Script path 'E:\Scoop Stuff\apps\clink-completions\0.4.1' installed. ❯ where clink E:\Scoop Stuff\shims\clink.cmd
I thought you meant it was a generic Command Prompt; but you must have meant CMD with Clink already injected.
Remember that Clink sets a doskey alias for clink
inside a Clink session. The clink
there is not invoking clink.bat
, it is invoking E:\Scoop Stuff\apps\clink\current\clink_x64.exe
and the clink.bat
is not executed at all.
When troubleshooting, it can be useful to try variations, and especially to try the most basic variation (in this case, plain CMD.exe without Clink).
❯ clink installscripts "E:\Scoop Stuff\apps\clink-completions\0.4.1" Stuff\apps\clink-completions\0.4.1""=="--autorun" was unexpected at this time. ❯ where clink E:\Scoop Stuff\shims\clink.cmd
When fixing #361, I added code to clink.bat
that inspects more arguments, more often.
I copied how Martin had been doing argument checks. But I wasn't paying close enough attention; the arguments checks were written in a way that produces errors when arguments are quoted and contain spaces or punctuation. clink.bat
had assumed no one would pass the first argument quoted; and indeed it would be unnecessary to do so -- but e.g. clink.bat "abc def"
breaks in a similar way.
Copying that syntax caused the fix for issue 361 to break with a quoted argument.
Commit 7e5f5abd2b829b66bedd7f2d610c3fb5e82a6510 fixes all of the argument parsing checks in clink.bat
to work properly with quoted arguments.
Remember that Clink sets a doskey alias for clink inside a Clink session. The clink there is not invoking clink.bat, it is invoking E:\Scoop Stuff\apps\clink\current\clink_x64.exe and the clink.bat is not executed at all.
Oh, right, it makes sense now.
Thank you so much for the speedy fix!
This is related to the Scoop manifest for clink-completions, which uses the
clink installscripts ...
command.It used to work perfectly fine, but now when using this command in PowerShell, this error comes up:
Same error pops up on the
uninstallscripts
command. However,It does not show an error when ran through Command Prompt:
The only place where I can think "autorun" is coming from could be here:
I'm not aware if anything changed in the
installscripts
command upstream. How can I fix this?