From d0f8ee75cda790dd022371b0c60e383166f75c33 Mon Sep 17 00:00:00 2001 From: CEbbinghaus Date: Thu, 14 Mar 2024 12:00:48 +1100 Subject: [PATCH] Changed from environment variable to config # Conflicts: # lib/core.ps1 --- lib/core.ps1 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/core.ps1 b/lib/core.ps1 index 671b61bb7e..1b5fce17b6 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' + # Scoop root directory $scoopdir = $env:SCOOP, (get_config ROOT_PATH), (Resolve-Path "$PSScriptRoot\..\..\..\.."), "$([System.Environment]::GetFolderPath('UserProfile'))\scoop" | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -First 1