Skip to content

Commit

Permalink
Merge pull request #145 from Fixstars-momoko/hotfix/pygobject-install…
Browse files Browse the repository at this point in the history
…er-env-val

Fixed the mess of system and user environment variable
  • Loading branch information
Fixstars-momoko authored Oct 1, 2024
2 parents 6eea188 + 07808de commit aae36a3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions installer/tools/pygobject_installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ param (
[string]$CacheDIR
)

$currentPath = $env:PATH

# saving PATH before pkg-config installation
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")

$pipExists = Get-Command pip -ErrorAction SilentlyContinue

Expand Down Expand Up @@ -52,6 +52,7 @@ try {
exit 1
}

# this environment variable update affects only in this session
$env:PATH = "$env:PATH;$pkgconfigDirectory"
Write-Output "Added $pkgconfigDirectory to PATH for the current session"

Expand Down Expand Up @@ -95,10 +96,12 @@ Write-Output "Removing PKG_CONFIG_PATH environment variable"
Remove-Item Env:\PKG_CONFIG_PATH

try{
Write-Output "Uninstalling $pkgConfigLiteAppId..."
winget uninstall --id $pkgConfigLiteAppId --accept-source-agreements
Write-Output "Clean up environment variable PATH..."
[Environment]::SetEnvironmentVariable("Path", $currentPath, "User")
Write-Output "Removing $pkgconfigDirectory from PATH"
} catch {
Write-Error "Successfully installed PyGObject but failed to remove tentative PATH"
Write-Error "Successfully installed PyGObject but failed to uninstall pkg-config"
}

Write-Output "Script completed."
Expand Down

0 comments on commit aae36a3

Please sign in to comment.