-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
move default config file from userprofile\.config to scoop\persist - Update core.ps1 #6600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1260,7 +1260,8 @@ function Out-UTF8File { | |||||||||||||
| Optimize-SecurityProtocol | ||||||||||||||
|
|
||||||||||||||
| # Load Scoop config | ||||||||||||||
| $configHome = $env:XDG_CONFIG_HOME, "$env:USERPROFILE\.config" | Select-Object -First 1 | ||||||||||||||
| $legacyConfig = if (Test-Path "$env:USERPROFILE\.config") { "$env:USERPROFILE\.config" } | ||||||||||||||
| $configHome = $env:XDG_CONFIG_HOME, $legacyConfig, "$PSScriptRoot\..\..\..\..\persist" | Select-Object -First 1 | ||||||||||||||
| $configFile = "$configHome\scoop\config.json" | ||||||||||||||
|
Comment on lines
+1263
to
1265
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug:
Follow the existing pattern used on Line 1292 for Proposed fix-$configHome = $env:XDG_CONFIG_HOME, $legacyConfig, "$PSScriptRoot\..\..\..\..\persist" | Select-Object -First 1
+$configHome = $env:XDG_CONFIG_HOME, $legacyConfig, "$PSScriptRoot\..\..\..\..\persist" | Where-Object { $_ } | Select-Object -First 1📝 Committable suggestion
Suggested change
🧰 Tools🪛 PSScriptAnalyzer (1.23.0)[warning] Missing BOM encoding for non-ASCII encoded file 'core.ps1' (PSUseBOMForUnicodeEncodedFile) 🤖 Prompt for AI Agents |
||||||||||||||
| # Check if it's the expected install path for scoop: <root>/apps/scoop/current | ||||||||||||||
| $coreRoot = Split-Path $PSScriptRoot | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$legacyConfigchecks directory existence but the path semantics have shifted.The legacy path
"$env:USERPROFILE\.config"is a directory, while the new persist path on Line 1264 ("$PSScriptRoot\..\..\..\..\persist") is also a directory — both used as a config home prefix for"$configHome\scoop\config.json". However, the legacy.configdirectory is validated withTest-Pathwhile the persist path is not. A non-existent persist directory would still be selected as the fallback, which may be intentional (config will be created there), but it means the legacy config is only preferred if the directory exists, not if the config file inside it exists.If a user has an empty
~\.configdirectory (common on Windows with cross-platform tools) but no~\.config\scoop\config.json, this will incorrectly select the legacy path over persist, and config loading will silently return$null.Consider checking for the actual config file instead:
Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 PSScriptAnalyzer (1.23.0)
[warning] Missing BOM encoding for non-ASCII encoded file 'core.ps1'
(PSUseBOMForUnicodeEncodedFile)
🤖 Prompt for AI Agents