-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(scoop-update): normalize $currentdir
to prevent unnecessary overwrite warning ScoopInstaller/Scoop#6277
#6485
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: develop
Are you sure you want to change the base?
Conversation
WalkthroughUpdated Sync-Scoop in libexec/scoop-update.ps1 to set $currentdir using Convert-Path on versiondir 'scoop' 'current', yielding an absolute path. Subsequent path checks and file operations that depend on $currentdir now resolve against an absolute path. No other logic or public interfaces changed. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal). Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
libexec/scoop-update.ps1 (1)
78-78
: Good normalization; add a safe fallback to avoid Convert-Path throws and potential junction deref surprises.Convert-Path requires the path to exist and may dereference junctions on some setups. A guarded fallback keeps behavior robust if 'apps\scoop\current' is missing/broken and avoids accidentally renaming the resolved target instead of the 'current' link during the non-git → git migration path.
Apply one of the following:
Option A (keep Convert-Path, add fallback)
- $currentdir = Convert-Path (versiondir 'scoop' 'current') + $currentdir = versiondir 'scoop' 'current' + try { + $currentdir = Convert-Path -Path $currentdir + } catch { + # Path might not exist or be a broken junction; normalize without requiring existence. + $currentdir = [System.IO.Path]::GetFullPath($currentdir) + }Option B (simpler, no existence requirement)
- $currentdir = Convert-Path (versiondir 'scoop' 'current') + $currentdir = [System.IO.Path]::GetFullPath((versiondir 'scoop' 'current'))Verification checklist (please run on Windows PowerShell 5+):
- With a trailing backslash in root_path, confirm shim "$currentdir\bin\scoop.ps1" no longer triggers warn_on_overwrite for scoop.
- When 'current' is a junction to a version dir, ensure Rename-Item behavior matches intent (renames the link, not the target).
To fix unnecessary overwrite warning mentioned in #6277
Description
The
$currentdir
variable inscoop-update.ps1
is not normalized. Under certain settings (e.g. path with a trailing '' in root_path config), it will cause unnecessary warnings about overwriting scoop shims during update.For example:
root_path
config has a trailing\
, the$currentdir
variable will carry a double\
when passed toshim
function.warn_on_overwrite
checks the shim file and path to compare app names. Due to the double slashes, theget_app_name
function will failed to match the correct app name (scoop in this case), and return a''
. Thus causing the warning.Motivation and Context
Relates to #6277 or #6194.
It fixes my errors but I'm not quite sure about other possible causes.
Anyway, normalizing a path variable should be considered good practice regardless.
How Has This Been Tested?
Checklist:
develop
branch.Summary by CodeRabbit