This is a split off of #833.
I'm trying to understand if refreshenv for powershell has been removed as a feature. If not, what is the correct way to load it? A few weeks ago you had to reload your profile, but it seems the profile is no longer updated.
@masaeedu it's still there as a feature, you just may need to manually add it. We introduced #833 to address the issues of creating a profile in many automation scenarios.
To add it manually for now when you install and there isn't a profile found or the profile file is missing.
$profileInstall = @'
# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
'@
$profileFile = "$profile"
$chocoProfileSearch = '$ChocolateyProfile'
if(Select-String -Path $profileFile -Pattern $chocoProfileSearch -Quiet -SimpleMatch) {
Write-Debug "Chocolatey profile is already installed."
return
}
$profileInstall | Out-File $profileFile -Append -Encoding (Get-FileEncoding $profileFile)
So just clarifying - this issue is about adding a new command to choco.exe that will add the Chocolatey bits to your PowerShell profile. This is for the scenario when you didn't have a $profile file when you first installed Chocolatey, and so the installer skipped that step.
@flcdrg yes, that's the idea.
Get-FileEncoding doesn't appear to be a standard module. Where can I get this?
Hey Chocolatey Team, I was fussing around with Powershell 7 Preview and added a function to my $PROFILE, actually related to Chocolatey. I tried running it this morning and found my function didn't work.
In troubleshooting I found that my $profile was modified with a Chocolatey Profile script. First off I think I have done a disservice to Choco as I didn't realize there was tab completion until today. When researching this I have been missing this since 2016, Yikes!
So something happened to my function and in its place the tab completion script. Not a big deal just wanted to add a comment about it here.
Anyhow it is awesome to have this feature.