diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a401905ca..29cd9bba4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - **depends:** Rewrite 'depends.ps1' ([#4638](https://github.com/ScoopInstaller/Scoop/issues/4638)) - **depends:** Keep bucket in 'Get-Dependency()' ([#4673](https://github.com/ScoopInstaller/Scoop/issues/4673)) +- **mklink:** Use 'New-Item' instead of 'mklink' ([#4690](https://github.com/ScoopInstaller/Scoop/issues/4690)) ### Builds diff --git a/lib/install.ps1 b/lib/install.ps1 index 758f33ee51..1b03cba1c7 100644 --- a/lib/install.ps1 +++ b/lib/install.ps1 @@ -927,7 +927,7 @@ function link_current($versiondir) { & "$env:COMSPEC" /c rmdir $currentdir } - & "$env:COMSPEC" /c mklink /j $currentdir $versiondir | out-null + New-Item -Path $currentdir -ItemType Junction -Value $versiondir | Out-Null attrib $currentdir +R /L return $currentdir } @@ -1154,15 +1154,15 @@ function persist_data($manifest, $original_dir, $persist_dir) { if (Test-Path $source) { Move-Item -Force $source "$source.original" } - # we don't have persist data in the store, move the source to target, then create link + # we don't have persist data in the store, move the source to target, then create link } elseif (Test-Path $source) { # ensure target parent folder exist ensure (Split-Path -Path $target) | Out-Null Move-Item $source $target - # we don't have neither source nor target data! we need to crate an empty target, - # but we can't make a judgement that the data should be a file or directory... - # so we create a directory by default. to avoid this, use pre_install - # to create the source file before persisting (DON'T use post_install) + # we don't have neither source nor target data! we need to crate an empty target, + # but we can't make a judgement that the data should be a file or directory... + # so we create a directory by default. to avoid this, use pre_install + # to create the source file before persisting (DON'T use post_install) } else { $target = New-Object System.IO.DirectoryInfo($target) ensure $target | Out-Null @@ -1171,11 +1171,11 @@ function persist_data($manifest, $original_dir, $persist_dir) { # create link if (is_directory $target) { # target is a directory, create junction - & "$env:COMSPEC" /c "mklink /j `"$source`" `"$target`"" | out-null + New-Item -Path $source -ItemType Junction -Value $target | Out-Null attrib $source +R /L } else { # target is a file, create hard link - & "$env:COMSPEC" /c "mklink /h `"$source`" `"$target`"" | out-null + New-Item -Path $source -ItemType HardLink -Value $target | Out-Null } } } diff --git a/lib/psmodules.ps1 b/lib/psmodules.ps1 index c2a9c7eb4f..539f1b47ee 100644 --- a/lib/psmodules.ps1 +++ b/lib/psmodules.ps1 @@ -26,7 +26,7 @@ function install_psmodule($manifest, $dir, $global) { & "$env:COMSPEC" /c "rmdir `"$linkfrom`"" } - & "$env:COMSPEC" /c "mklink /j `"$linkfrom`" `"$dir`"" | out-null + New-Item -Path $linkfrom -ItemType Junction -Value $dir | Out-Null } function uninstall_psmodule($manifest, $dir, $global) {