Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fixing the documentation upload step in the build pipeline.
- Added missing RequiredModules entry for platyPS.
- Fixed issue where Repair-ProcessEnvPath always set the Process level Path variable.
- Show warning when uninstalling a discovery package that is not a .install or
.portable package.

## [0.10.2] - 2025-10-23

Expand Down
22 changes: 16 additions & 6 deletions source/private/Repair-ProcessEnvPath.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ excluding the specified paths.
#>
function Repair-ProcessEnvPath
{
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', $null, Scope='Function', Justification = 'Used within the function.')]
[CmdletBinding()]
param
(
Expand All @@ -36,6 +37,7 @@ function Repair-ProcessEnvPath
$ExcludedPaths = @()
)

[bool]$pathMissing = $false
# Store the current $Env:Path
[string[]]$currentEnvPaths = ($Env:Path -split [IO.Path]::PathSeparator).ForEach{ $_.ToLower().TrimEnd('\') }
# Add any missing entries from Machine level Path variable
Expand All @@ -45,20 +47,28 @@ function Repair-ProcessEnvPath
-not [string]::IsNullOrEmpty($_) -and
# remove paths already in current $Env:Path
-not $currentEnvPaths.Contains($_.ToLower().TrimEnd('\'))
}.ForEach{
}.ForEach({
# Add missing paths to $PathVarAtLoadTime
Write-Debug -Message ("Adding missing Path entry from Machine level: {0}" -f $_)
$PathVarAtLoadTime += $_
}
$pathMissing = $true
})

# excluding any in $ExcludedPaths
$ExcludedPaths = $ExcludedPaths.ForEach{ $_.ToLower().TrimEnd('\') }
$PathVarAtLoadTime = $PathVarAtLoadTime.Where{
-not $ExcludedPaths.Contains($_.ToLower().TrimEnd('\'))
}

# Finally, set the Process level Path variable
Write-Debug -Message ('Setting Process level Path variable: {0}{1}' -f "`r`n",($PathVarAtLoadTime -join "`r`n"))
$Env:Path = $PathVarAtLoadTime -join [IO.Path]::PathSeparator
[Environment]::SetEnvironmentVariable('Path', $Env:Path, 'Process')
# Finally, set the Process level Path variable if needed
if ($PathVarAtLoadTime.count -eq $currentEnvPaths.count -and -not $pathMissing)
{
Write-Debug -Message 'No changes made to Process level Path variable ($Env:Path)'
}
else
{
Write-Debug -Message ('Setting Process level Path variable: {0}{1}' -f "`r`n",($PathVarAtLoadTime -join "`r`n"))
$Env:Path = $PathVarAtLoadTime -join [IO.Path]::PathSeparator
[Environment]::SetEnvironmentVariable('Path', $Env:Path, 'Process')
}
}
2 changes: 1 addition & 1 deletion source/public/package/Get-ChocolateyPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function Get-ChocolateyPackage

$chocoArguments += Get-ChocolateyDefaultArgument @PSBoundParameters

if ($ByPassCache.IsPresent -or $Exact.IsPresent)
if ($ByPassCache.IsPresent -or -not $Exact.IsPresent)
{
# bypass caching when requested, or when not searching for an exact match
# (when not doing exact match choco is looking through description)
Expand Down
9 changes: 8 additions & 1 deletion source/public/package/Uninstall-ChocolateyPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,14 @@ function Uninstall-ChocolateyPackage
$ChocoArguments += @('-y')
Write-Debug -Message ('{0} {1}' -f $chocoCmd, $($ChocoArguments -join ' '))
&$chocoCmd $ChocoArguments | Foreach-Object -Process {
Write-Verbose -Message ('{0}' -f $_)
if ($_ -match '^You are uninstalling .* which is likely|\*\.install/\*\.portable|represents discoverability')
{
Write-Warning -Message ('{0}' -f $_)
}
else
{
Write-Verbose -Message ('{0}' -f $_)
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/public/software/Get-ChocolateyCommand.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function Get-ChocolateyCommand
$script:ChocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'Stop')[0]
}

Write-Verbose -Message ('Chocolatey Software found in {0} with file version {1}' -f $script:ChocoCmd.Path, $script:ChocoCmd.Version)
Write-Debug -Message ('Chocolatey Software found in {0} with file version {1}' -f $script:ChocoCmd.Path, $script:ChocoCmd.Version)

return $script:ChocoCmd
}
Expand Down
5 changes: 3 additions & 2 deletions source/public/software/Install-ChocolateySoftware.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ function Install-ChocolateySoftware
[Environment]::SetEnvironmentVariable('ChocolateyInstall', $InstallationDirectory, 'Machine')
}

& $chocInstallPS1 | Foreach-Object -Process {
#TODO: Capture output and log to file? *>&1
$null = & $chocInstallPS1 | Foreach-Object -Process {
Write-Verbose -Message ('{0}' -f $_)
}

Expand Down Expand Up @@ -293,6 +294,6 @@ function Install-ChocolateySoftware

if ($ChocoVersion = & "$chocoPath\choco.exe" @('-v'))
{
Write-Verbose ('Installed Chocolatey Version: {0}'-f $ChocoVersion)
Write-Verbose -Message ('Installed Chocolatey Version: {0}'-f $ChocoVersion)
}
}
Loading