fix(git): Don't execute autostart programs when executing git commands #3993
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The way the current code works is that it has side effects when trying to execute a git command.
(This comes from the file git.ps1 in the lib directory).
(i.e current code
& "$env:COMSPEC" /c $cmd
)
Without the /d parameter, it also executes code that is in the windows autostart sections of the registry.
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
and/or
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
by adding the /d switch
& "$env:COMSPEC" /d /c $cmd
no extra autorun programs will be executed.
Normally, this does not have any adverse effects (it is just possibly slower), however, if there is an error in the autostart entries, it ends up returning errors to scoop that get interpreted incorrectly. In my case, I also had invalid entries left in the autostart and was receiving the error message -
"The system cannot find the path specified". And scoop was failing.
I have seen this reported on several bugs as well.
Of course, there are several fixes to this - remove the entries from the registry, but I believe by adding the /d switch to the line below, will save scoop reporting errors that are non-related to scoop and it will run potentially faster when the autostart programs are time-consuming.