Skip to content

Commit d0f8ee7

Browse files
committed
Changed from environment variable to config
# Conflicts: # lib/core.ps1
1 parent 418ab78 commit d0f8ee7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/core.ps1

+8-5
Original file line numberDiff line numberDiff line change
@@ -740,10 +740,11 @@ public static extern IntPtr SendMessageTimeout(
740740

741741
function env($name, $global, $val = '__get') {
742742
if(-not $name) {
743-
$name = [environment]::getEnvironmentVariable("SCOOP_ENV", "User")
744-
if(-not $name) {
745-
$name = 'PATH'
746-
}
743+
$name = $scoop_path_env
744+
}
745+
746+
if(-not $name) {
747+
throw "Unable to evaluate path environment variable. Please set or remove PATH_ENV in your config.json."
747748
}
748749

749750
$RegisterKey = if ($global) {
@@ -755,7 +756,7 @@ function env($name, $global, $val = '__get') {
755756

756757
if ($val -eq '__get') {
757758
$RegistryValueOption = [Microsoft.Win32.RegistryValueOptions]::DoNotExpandEnvironmentNames
758-
$EnvRegisterKey.GetValue($name, $null, $RegistryValueOption)
759+
$EnvRegisterKey.GetValue($name, $null, $RegistryValueOption) + ""
759760
} elseif ($val -eq $null) {
760761
try { $EnvRegisterKey.DeleteValue($name) } catch { }
761762
Publish-Env
@@ -1422,6 +1423,8 @@ if ($pathExpected) {
14221423
}
14231424
$scoopConfig = load_cfg $configFile
14241425

1426+
$scoop_path_env = get_config PATH_ENV 'PATH'
1427+
14251428
# Scoop root directory
14261429
$scoopdir = $env:SCOOP, (get_config ROOT_PATH), (Resolve-Path "$PSScriptRoot\..\..\..\.."), "$([System.Environment]::GetFolderPath('UserProfile'))\scoop" | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -First 1
14271430

0 commit comments

Comments
 (0)