Scoop
Scoop copied to clipboard
Scoop breaks its own installation on update because it uses user's Git configuration
I've got a custom .gitconfig Git configuration, and each time I try to scoop update *, Scoop breaks its own installation:
$ scoop update *
Updating Scoop...
gpg: keyserver option 'verbose' is unknown
gpg: signing failed: No secret key
gpg: signing failed: No secret key
error: gpg failed to sign the data
fatal: failed to write commit object
Update failed.
In my particular case, I suspect the commit.gpgSign Git option to break Scoop. A solution could comment/delete the responsible line.
But a better solution should be to make Scoop have its own gitconfig file.
Let me add more information with the new bug report template.
Bug Report
Current Behavior
Running scoop update leads to a inconsistent state of the buckets because Scoop reads the global Git configuration file (~/.config/git/config).
On scoop update, a GPG pinentry pops up asking for my GPG passphrase to sign the new merge commit. But I just click Cancel since I’m not going to sign the merge commit. I get the following output:
❯ scoop update
Updating Scoop...
Updating 'extras' bucket...
* dac4f25b8 winsshterm: Update to version 2.18.0 23 minutes ago
* 9a5a7cb42 github: Update to version 2.9.10 23 minutes ago
Updating 'games' bucket...
Updating 'main' bucket...
gpg: échec de la signature : Opération annulée
gpg: signing failed: Opération annulée
error: gpg failed to sign the data
fatal: failed to write commit object
Scoop was updated successfully!
On a new scoop update, I get the following output:
❯ scoop update
Updating Scoop...
Updating 'extras' bucket...
Updating 'games' bucket...
Updating 'main' bucket...
error: You have not concluded your merge (MERGE_HEAD exists).
hint: Please, commit your changes before merging.
fatal: Exiting because of unfinished merge.
Scoop was updated successfully!
Then I need to git reset --hard every bucket I have added.
Expected Behavior
Scoop should not uses the user’s Git configuration file on scoop update.
It should either ignore user’s Git configuration file, or have its own overriding Git configuration file to update the buckets. A major benefit is that Scoop becomes much more resilient against exotic user Git configurations.
Additional context/output
In my ~/.config/git/config file, I have this specific entries:
# …
[merge]
ff = false
[commit]
gpgSign = true
# …
The described behaviour is due to the merge.ff = false configuration. By default, I believe it is set to true. This tells Git to add a merge commit even if there is no conflict.
Possible Solution
To ignore the user’s Git configuration file, Scoop could set the GIT_CONFIG_GLOBAL to /dev/null. See the official documentation.
The workaround I use is to add the following snippet in every buckets I have added. For instance, in %USERPROFILE%\scoop\buckets\extras\.git\config.
# …
[merge]
ff = true
System details
Windows version: 10
OS architecture: 64bit
PowerShell version: 7.2.1
Additional software: Git 2.35.1.windows.2
Scoop Configuration
{
"lastupdate": "2022-02-23T13:55:18.9889019+01:00",
"SCOOP_REPO": "https://github.com/lukesampson/scoop",
"SCOOP_BRANCH": "master"
}
There is a similar problem reported here - https://github.com/ScoopInstaller/Scoop/issues/4166
Similar issue if you have a passphrase on your SSH key. I just ran scoop update * and needed to enter the passphrase on my key for every bucket it needed to update.
In theory it shouldn't need the user's .gitconfig or SSH key to clone buckets. HTTPS clone should work.
I'm filing all gitconfig issues in this common thread
From @0x326 in #4166:
Issue
A user might set
git config --global merge.verifySignatures trueaccording to their typical Git workflow. Enabling this setting breaks Scoop'sgit pullsince buckets typically do not sign Git commits.Solution
Set
git config --local merge.verifySignatures falsein~/scoop/bucketsrepositories or rungit pull --no-verify-signatureswhen performing updates.
From @Twoleeland in #5070:
Current Behavior
Running PowerShell (
pswh.exeandpowershell.exe) as Admin, trying to update scoop (or adding bucket "extras") results in error:fatal: invalid branch name: init.defaultBranch=Expected Behavior
- Scoop should set itself
init.defaultBranchor better, use a default value likemaster, ifinit.defaultBranchis empty (or not set or null), regardless of user mode (normal or elevated).- Error messages, like the above, should include the app name which is causing the error: -> in this case, "Git for Windows" which caused above error. -> till I found out what was causing this error, several hours were gone, because I thought it was a fault of Scoop and not Git! 😉
Possible Solution
After executing
git config --global init.defaultBranch masterdescribed at StackOverflow Git Error "fatal: invalid branch name: init.defaultBranch =", I could update Scoop and add the bucket "extras" without any problems anymore.It would be far better if you could set default values within Scoop that can be used by Scoop when such values as
init.defaultBranchare set incorrectly or even not set at all. Or add a default configuration for Git (- and also for other tools you use in Scoop -) and use the values of this configuration if the values are not set correctly as expected by Scoop. This way, such errors could be avoided in the future! 😉Translated with www.DeepL.com/Translator (free version)
Forget to add this info:
After fresh install of Scoop through "Advanced Installation" with similar commands as following (important: -RunAsAdmin used):
irm get.scoop.sh -outfile 'install.ps1'
.\install.ps1 -RunAsAdmin -ScoopDir 'D:\Applications\Scoop' -ScoopGlobalDir 'F:\GlobalScoopApps' -NoProxy
Using scoop update with global init.defaultBranch not set, this error happens in core.ps1 of Scoop in scoop\current\lib\: function git_cmd - at line 134 is the exception thrown. 😉
UPDATE:
And I tested it again by deleting all files in "ScoopDir" and removing master from global init.defaultBranch of "Git for Windows". Then, installing Scoop with "-RunAsAdmin" in elevated PowerShell with Admin Rights and try only to execute scoop update. Same result as I wrote before:
Updating Scoop...
fatal: invalid branch name: init.defaultBranch =
Remove-Item: C:\Scoop\Apps\apps\scoop\current\libexec\scoop-update.ps1:77
Line |
77 | Remove-Item $newdir -Force -Recurse
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot find path 'C:\Scoop\Apps\apps\scoop\new' because it does not exist.
Scoop download failed. If this appears several times, try removing SCOOP_REPO by 'scoop config rm SCOOP_REPO'
Adding back master in global init.defaultBranch and executing scoop update:
Updating Scoop...
Updating 'main' bucket...
Converting 'main' bucket to git repo...
Checking repo... OK
The main bucket was added successfully.
Scoop was updated successfully!
And if you remove master after updating Scoop, it works without it! 😉
Hope, this helps to correct the initial scoop update after fresh install of Scoop.
Best regards