From 17659256cfb6d92d8684570a88ad51a6664f62ab Mon Sep 17 00:00:00 2001 From: CEbbinghaus Date: Tue, 27 Feb 2024 19:05:22 +1100 Subject: [PATCH] Changed from environment variable to config --- lib/core.ps1 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/core.ps1 b/lib/core.ps1 index 80d6554cf4..865851f594 100644 --- a/lib/core.ps1 +++ b/lib/core.ps1 @@ -740,10 +740,11 @@ public static extern IntPtr SendMessageTimeout( function env($name, $global, $val = '__get') { if(-not $name) { - $name = [environment]::getEnvironmentVariable("SCOOP_ENV", "User") - if(-not $name) { - $name = 'PATH' - } + $name = $scoop_path_env + } + + if(-not $name) { + throw "Unable to evaluate path environment variable. Please set or remove PATH_ENV in your config.json." } $RegisterKey = if ($global) { @@ -755,7 +756,7 @@ function env($name, $global, $val = '__get') { if ($val -eq '__get') { $RegistryValueOption = [Microsoft.Win32.RegistryValueOptions]::DoNotExpandEnvironmentNames - $EnvRegisterKey.GetValue($name, $null, $RegistryValueOption) + $EnvRegisterKey.GetValue($name, $null, $RegistryValueOption) + "" } elseif ($val -eq $null) { try { $EnvRegisterKey.DeleteValue($name) } catch { } Publish-Env @@ -1422,6 +1423,8 @@ if ($pathExpected) { } $scoopConfig = load_cfg $configFile +$scoop_path_env = get_config PATH_ENV 'PATH' + # NOTE Scoop config file migration. Remove this after 2023/6/30 if ($scoopConfig -and $scoopConfig.PSObject.Properties.Name -contains 'lastUpdate') { $newConfigNames = @{