Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1309,3 +1309,6 @@ $scoopPathEnvVar = switch (get_config USE_ISOLATED_PATH) {

# OS information
$WindowsBuild = [System.Environment]::OSVersion.Version.Build

# Ensure .git folder exists to prevent Windows Search indexing
ensure "$scoopdir\.git" | Out-Null
Comment on lines +1313 to +1314
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's check the overall structure and find PowerShell files
ls -la lib/ | head -20

Repository: ScoopInstaller/Scoop

Length of output: 1262


🏁 Script executed:

# Search for git operations in scoop's PowerShell files
rg -n 'Invoke-Git|\.git|git ' lib/ --type=ps1 -A 2 -B 2 | head -100

Repository: ScoopInstaller/Scoop

Length of output: 91


🏁 Script executed:

# Check for bucket-related code and git operations
rg -n 'bucketsdir|buckets|bucket' lib/ --type=ps1 | head -50

Repository: ScoopInstaller/Scoop

Length of output: 91


🏁 Script executed:

# Look at the ensure function definition
sed -n '599,604p' lib/core.ps1

Repository: ScoopInstaller/Scoop

Length of output: 222


🏁 Script executed:

# Check the context around the new code (lines 1310-1320)
sed -n '1310,1320p' lib/core.ps1

Repository: ScoopInstaller/Scoop

Length of output: 245


🏁 Script executed:

# Search for git operations in all files in lib/
grep -rn 'Invoke-Git\|git ' lib/*.ps1 | head -50

Repository: ScoopInstaller/Scoop

Length of output: 1954


🏁 Script executed:

# Look at buckets.ps1 to understand bucket structure
cat lib/buckets.ps1

Repository: ScoopInstaller/Scoop

Length of output: 7452


🏁 Script executed:

# Search for where buckets directory is used
grep -n 'bucketsdir\|\$buckets' lib/*.ps1

Repository: ScoopInstaller/Scoop

Length of output: 866


🏁 Script executed:

# Check if scoop itself is a git repo and how it's structured
head -20 lib/core.ps1 | grep -i git

Repository: ScoopInstaller/Scoop

Length of output: 46


🏁 Script executed:

# Look for any existing git directory handling
grep -rn '\.git' lib/*.ps1

Repository: ScoopInstaller/Scoop

Length of output: 1447


🏁 Script executed:

# Look at the Invoke-Git function
sed -n '219,260p' lib/core.ps1

Repository: ScoopInstaller/Scoop

Length of output: 1328


🏁 Script executed:

# Confirm the git directory structure in buckets
grep -n 'Test-Path.*\.git' lib/buckets.ps1

Repository: ScoopInstaller/Scoop

Length of output: 235


Creating a fake .git directory will break scoop's bucket git operations.

Scoop stores buckets as git repositories under $scoopdir\buckets\<name>\.git and executes git commands directly in these directories (e.g., git config remote.origin.url, git log). When git runs in any bucket directory, it walks up the directory tree to find the repository root. A fake .git at $scoopdir (the parent directory) will be discovered first, causing git to misidentify the repository root and breaking bucket operations. Additionally, git-aware tools (VS Code, IDEs, etc.) will detect this fake .git as a corrupted repository.

Consider these alternatives to exclude the scoop directory from Windows Search:

  • Add $scoopdir to the Windows Search exclusion list programmatically (via registry or COM)
  • Use Windows desktop.ini with appropriate attributes
  • If .git is necessary, test thoroughly before deployment as it will directly impact bucket management
🧰 Tools
🪛 PSScriptAnalyzer (1.23.0)

[warning] Missing BOM encoding for non-ASCII encoded file 'core.ps1'

(PSUseBOMForUnicodeEncodedFile)

🤖 Prompt for AI Agents
In `@lib/core.ps1` around lines 1313 - 1314, Remove the call that creates a fake
.git folder (the ensure "$scoopdir\.git" | Out-Null line) because it breaks Git
bucket operations; instead, stop creating $scoopdir\.git and replace it with a
non-Git approach such as invoking a new helper (e.g.,
Add-DirectoryToSearchExclusion or Set-DesktopIniExclusion) with $scoopdir as the
argument to add $scoopdir to Windows Search exclusions or apply a
desktop.ini-based exclusion; update any callers or documentation to reference
the new helper and ensure the ensure function is no longer used to create
$scoopdir\.git.