Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (chocolatey-archiveGH-460) Fix for "Package depending on newer chocolatey is installed using existing chocolatey"
  (chocolatey-archiveGH-459) Fix for "Cannot find Update-SessionInformation"
  (maint) formatting
  (chocolatey-archiveGH-153)(chocolatey-archiveGH-134) Update PATH on cmd.exe
  (maint) ensure powershell module loading preference is on
  • Loading branch information
ferventcoder committed Jun 16, 2014
2 parents c1ab0a6 + 54fca9b commit 56626c2
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 30 deletions.
3 changes: 3 additions & 0 deletions nuget/tools/chocolateyInstall.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
$toolsPath = (Split-Path -parent $MyInvocation.MyCommand.Definition)

# ensure module loading preference is on
$PSModuleAutoLoadingPreference = "All";

$modules = Get-ChildItem $toolsPath -Filter *.psm1
$modules | ForEach-Object {
$psm1File = $_.FullName;
Expand Down
7 changes: 4 additions & 3 deletions nuget/tools/chocolateysetup.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ param(
)

$installModule = Join-Path $thisScriptFolder 'chocolateyInstall\helpers\chocolateyInstaller.psm1'
Import-Module $installModule
Import-Module $installModule -Force

if ($chocolateyPath -eq '') {
$programData = [Environment]::GetFolderPath("CommonApplicationData")
Expand Down Expand Up @@ -73,7 +73,8 @@ Creating Chocolatey NuGet folders if they do not already exist.
Initialize-ChocolateyPath $chocolateyExePath $chocolateyExePathVariable
Process-ChocolateyBinFiles $chocolateyExePath $chocolateyExePathVariable
Install-DotNet4IfMissing $chocolateyInstallPath
Remove-Module ChocolateyInstaller
$realModule = Join-Path $chocolateyInstallPath "helpers\chocolateyInstaller.psm1"
Import-Module "$realModule" -Force

@"
Chocolatey is now ready.
Expand Down Expand Up @@ -113,7 +114,7 @@ param(
)

$redirectsPath = Join-Path $chocolateyInstallPath 'redirects'
$exeFiles = Get-ChildItem "$redirectsPath" -filter *.exe
$exeFiles = Get-ChildItem "$redirectsPath" -include @("*.exe","*.cmd") -recurse
foreach ($exeFile in $exeFiles) {
$exeFilePath = $exeFile.FullName
$exeFileName = [System.IO.Path]::GetFileName("$exeFilePath")
Expand Down
1 change: 0 additions & 1 deletion src/chocolatey.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ IF NOT '%1'=='' SET PS_ARGS=%PS_ARGS:\\"=\"%

@PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%DIR%chocolatey.ps1' %PS_ARGS%"
SET ErrLvl=%ERRORLEVEL%
call "%DIR%RefreshEnv.cmd"
goto :exit

:exit
Expand Down
2 changes: 2 additions & 0 deletions src/chocolatey.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ if ($debug) {
$DebugPreference = "Continue";
$env:ChocolateyEnvironmentDebug = 'true'
}
# ensure module loading preference is on
$PSModuleAutoLoadingPreference = "All";

$installModule = Join-Path $nugetChocolateyPath (Join-Path 'helpers' 'chocolateyInstaller.psm1')
Import-Module $installModule
Expand Down
4 changes: 2 additions & 2 deletions src/functions/Chocolatey-NuGet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ Write-Debug "Installing packages to `"$nugetLibPath`"."
}
}

Update-SessionEnvironment
Write-Host "Finished installing `'$packageName`' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure." -ForegroundColor $RunNote -BackgroundColor Black
Update-SessionEnvironment
Write-Host "Finished installing `'$packageName`' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure." -ForegroundColor $RunNote -BackgroundColor Black
}
18 changes: 9 additions & 9 deletions src/helpers/functions/Update-SessionEnvironment.ps1
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
function Update-SessionEnvironment {
<#
.SYNOPSIS
Updates the environment variables of the current powershell session with
any environment variable changes that may have occured during a chocolatey
Updates the environment variables of the current powershell session with
any environment variable changes that may have occured during a chocolatey
package install.
.DESCRIPTION
When chocolatey installs a package, the package author may ad or change
certain environment variables that will affect how the application runs
or how it is accessed. Often, these changes are not visible to the current
powershell session. This means the user needs to open a new powershell
session before these settings take effect which can render the installed
When chocolatey installs a package, the package author may add or change
certain environment variables that will affect how the application runs
or how it is accessed. Often, these changes are not visible to the current
powershell session. This means the user needs to open a new powershell
session before these settings take effect which can render the installed
application unfunctional until that time.
Use the Update-SessionEnvironment command to refresh the current
powershell session with all environment settings possibly performed by
Use the Update-SessionEnvironment command to refresh the current
powershell session with all environment settings possibly performed by
chocolatey package installs.
#>
Expand Down
21 changes: 6 additions & 15 deletions src/RefreshEnv.cmd → src/redirects/RefreshEnv.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@
::
:: With this batch file, there should be no need to reload command
:: environment every time you want environment changes to propagate
::

:: A strange trick to print without newline
:: echo | set /p dummy="Reading environment variables from registry. Please wait... "
echo | set /p dummy="Reading environment variables from registry. Please wait... "

goto main

:: Set one environment variable from registry key
:SetFromReg
"%WinDir%\System32\Reg" QUERY "%~1" /v "%~2" > "%TEMP%\_envset.tmp" 2>NUL
for /f "usebackq skip=2 tokens=2,*" %%A IN ("%TEMP%\_envset.tmp") do (
echo/set "%~3=%%B"
echo/set %~3=%%B
)
goto :EOF

Expand All @@ -43,11 +42,7 @@ goto main
call :SetFromReg "HKCU\Environment" Path Path_HKCU >> "%TEMP%\_env.cmd"

:: Caution: do not insert space-chars before >> redirection sign
echo/set "Path=%%Path_HKLM%%;%%Path_HKCU%%" >> "%TEMP%\_env.cmd"

:: In final file: remove temp variables
echo/set "Path_HKLM=" >> "%TEMP%\_env.cmd"
echo/set "Path_HKCU=" >> "%TEMP%\_env.cmd"
echo/set Path=%%Path_HKLM%%;%%Path_HKCU%% >> "%TEMP%\_env.cmd"

:: Cleanup
del /f /q "%TEMP%\_envset.tmp" 2>nul
Expand All @@ -56,9 +51,5 @@ goto main
:: Set these variables
call "%TEMP%\_env.cmd"

:: Finish
:: echo | set /p dummy="Done"
::echo .


exit /b %ERRORLEVEL%
echo | set /p dummy="Done"
echo .

0 comments on commit 56626c2

Please sign in to comment.