Skip to content

Commit

Permalink
Make SCOOP_PATH as default PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
niheaven committed Apr 13, 2024
1 parent 412c903 commit a2b13b3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 46 deletions.
37 changes: 1 addition & 36 deletions lib/core.ps1
Expand Up @@ -161,42 +161,7 @@ function Complete-ConfigChange {
[string]
$Value
)

if ($Name -eq 'use_isolated_path') {
. "$PSScriptRoot\..\lib\system.ps1"

if ($Value -eq $true) {
info 'Switching to isolated path... This may take a while, please wait.'
$movedPath = Remove-Path -Path "$scoopdir\apps\*" -Quiet -PassThru
if ($movedPath) {
Add-Path -Path $movedPath -TargetEnvVar 'SCOOP_PATH' -Quiet
Add-Path -Path '%SCOOP_PATH%' -Quiet
}
if (is_admin) {
$movedPath = Remove-Path -Path "$globaldir\apps\*" -Global -Quiet -PassThru
if ($movedPath) {
Add-Path -Path $movedPath -TargetEnvVar 'SCOOP_PATH' -Global -Quiet
Add-Path -Path '%SCOOP_PATH%' -Global -Quiet
}
}
} else {
info 'Switching to shared path... This may take a while, please wait.'
$movedPath = Get-EnvVar -Name 'SCOOP_PATH'
if ($movedPath) {
Add-Path -Path $movedPath -Quiet
Remove-Path -Path '%SCOOP_PATH%' -Quiet
Set-EnvVar -Name 'SCOOP_PATH' -Quiet
}
if (is_admin) {
$movedPath = Get-EnvVar -Name 'SCOOP_PATH' -Global
if ($movedPath) {
Add-Path -Path $movedPath -Global -Quiet
Remove-Path -Path '%SCOOP_PATH%' -Global -Quiet
Set-EnvVar -Name 'SCOOP_PATH' -Global -Quiet
}
}
}
}
# Add needed config change logic here
}

function setup_proxy() {
Expand Down
8 changes: 2 additions & 6 deletions lib/install.ps1
Expand Up @@ -906,13 +906,9 @@ function env_add_path($manifest, $dir, $global, $arch) {
$env_add_path = arch_specific 'env_add_path' $manifest $arch
$dir = $dir.TrimEnd('\')
if ($env_add_path) {
$target_path = 'PATH'
if (get_config USE_ISOLATED_PATH) {
Add-Path -Path '%SCOOP_PATH%' -Global:$global
$target_path = 'SCOOP_PATH'
}
Add-Path -Path '%SCOOP_PATH%' -Global:$global
$path = $env_add_path.Where({ $_ }).ForEach({ Join-Path $dir $_ | Get-AbsolutePath }).Where({ is_in_dir $dir $_ })
Add-Path -Path $path -TargetEnvVar $target_path -Global:$global -Force
Add-Path -Path $path -TargetEnvVar 'SCOOP_PATH' -Global:$global -Force
}
}

Expand Down
4 changes: 0 additions & 4 deletions libexec/scoop-config.ps1
Expand Up @@ -115,10 +115,6 @@
# Nightly version is formatted as 'nightly-yyyyMMdd' and will be updated after one day if this is set to $true.
# Otherwise, nightly version will not be updated unless `--force` is used.
#
# use_isolated_path: $true|$false
# When set to $true, Scoop will use `SCOOP_PATH` environment variable to store apps' `PATH`s.
# This is useful when you want to isolate Scoop from the system `PATH`.
#
# ARIA2 configuration
# -------------------
#
Expand Down
16 changes: 16 additions & 0 deletions libexec/scoop-update.ps1
Expand Up @@ -57,6 +57,22 @@ if(($PSVersionTable.PSVersion.Major) -lt 5) {
}
$show_update_log = get_config SHOW_UPDATE_LOG $true

# Migrate PATH EnvVar to SCOOP_PATH
$movedPath = Remove-Path -Path "$scoopdir\apps\*" -Quiet -PassThru
if ($movedPath) {
info 'Switching to isolated path... This may take a while, please wait.'
Add-Path -Path $movedPath -TargetEnvVar 'SCOOP_PATH' -Quiet
Add-Path -Path '%SCOOP_PATH%' -Quiet
}
if (is_admin) {
$movedPath = Remove-Path -Path "$globaldir\apps\*" -Global -Quiet -PassThru
if ($movedPath) {
info 'Switching to isolated global path... This may take a while, please wait.'
Add-Path -Path $movedPath -TargetEnvVar 'SCOOP_PATH' -Global -Quiet
Add-Path -Path '%SCOOP_PATH%' -Global -Quiet
}
}

function Sync-Scoop {
[CmdletBinding()]
Param (
Expand Down

0 comments on commit a2b13b3

Please sign in to comment.