Skip to content
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

fix(install)!: show fs type and abort if Junction creation fails (#5367) #6052

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- **sqlite:** Fix compatibility with Windows PowerShell ([#6045](https://github.com/ScoopInstaller/Scoop/issues/6045))
- **install:** Expand `env_set` items before setting Environment Variables ([#6050](https://github.com/ScoopInstaller/Scoop/issues/6050))
- **install:** Show filesystem type and abort if Junction creation fails ([#5367](https://github.com/ScoopInstaller/Scoop/discussions/5367))
- **bucket:** Implement error handling for failed bucket addition ([#6051](https://github.com/ScoopInstaller/Scoop/issues/6051))

## [v0.5.0](https://github.com/ScoopInstaller/Scoop/compare/v0.4.2...v0.5.0) - 2024-07-01
Expand Down
20 changes: 16 additions & 4 deletions lib/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1120,9 +1120,21 @@ function test_running_process($app, $global) {
# Required to handle docker/for-win#12240
function New-DirectoryJunction($source, $target) {
# test if this script is being executed inside a docker container
if (Get-Service -Name cexecsvc -ErrorAction SilentlyContinue) {
cmd.exe /d /c "mklink /j `"$source`" `"$target`""
} else {
New-Item -Path $source -ItemType Junction -Value $target
try {
if (Get-Service -Name cexecsvc -ErrorAction SilentlyContinue) {
cmd.exe /d /c "mklink /j `"$source`" `"$target`""
if ($lastexitcode -gt 0) {
throw System.ComponentModel.Win32Exception
}
} else {
New-Item -Path $source -ItemType Junction -Value $target -ErrorAction Stop
}
}
catch [System.ComponentModel.Win32Exception] {
# for non-NTFS filesystem, Junction creation may fail; in this case, showing FileSystemType helps to locate the issue
$target_path = Resolve-Path $target
$drive_letter = (Split-Path -Path $target_path -Qualifier).Trim(":")
warn "FileSystemType of target path $($target_path): $((Get-Volume -DriveLetter $drive_letter).FileSystemType)"
abort "Cannot link $(friendly_path $source) => $(friendly_path $target)"
}
}