Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start-ChocolateyProcessAsAdmin Module Import for PowerShell causes errors #901

Closed
sergey-s-betke opened this issue Aug 9, 2016 · 11 comments

Comments

@sergey-s-betke
Copy link

sergey-s-betke commented Aug 9, 2016

What You Are Seeing?

On Start-ChocolateyProcessAsAdmin (signcode.install v1.0.2):

#< CLIXML
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Подготовка модулей к первому использованию.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="1"><TNRef RefId="0" /><MS><I64 N="SourceId">2</I64><PR N="Record"><AV>Подготовка модулей к первому использованию.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><S S="debug">Host version is 5.0.10586.494, PowerShell Version is '5.0.10586.494' and CLR Version is '4.0.30319.42000'.</S><S S="debug">Loading community extensions</S><S S="verbose">Экспорт функции "Format-FileSize".</S><S S="verbose">Экспорт функции "Get-ChecksumValid".</S><S S="verbose">Экспорт функции "Get-ChocolateyUnzip".</S><S S="verbose">Экспорт функции "Get-ChocolateyWebFile".</S><S S="verbose">Экспорт функции "Get-EnvironmentVariable".</S><S S="verbose">Экспорт функции "Get-EnvironmentVariableNames".</S><S S="verbose">Экспорт функции "Get-FtpFile".</S><S S="verbose">Экспорт функции "Get-OSArchitectureWidth".</S><S S="verbose">Экспорт функции "Get-ToolsLocation".</S><S S="verbose">Экспорт функции "Get-UACEnabled".</S><S S="verbose">Экспорт функции "Get-UninstallRegistryKey".</S><S S="verbose">Экспорт функции "Get-VirusCheckValid".</S><S S="verbose">Экспорт функции "Get-WebFile".</S><S S="verbose">Экспорт функции "Get-WebFileName".</S><S S="verbose">Экспорт функции "Get-WebHeaders".</S><S S="verbose">Экспорт функции "Install-BinFile".</S><S S="verbose">Экспорт функции "Install-ChocolateyDesktopLink".</S><S S="verbose">Экспорт функции "Install-ChocolateyEnvironmentVariable".</S><S S="verbose">Экспорт функции "Install-ChocolateyExplorerMenuItem".</S><S S="verbose">Экспорт функции "Install-ChocolateyFileAssociation".</S><S S="verbose">Экспорт функции "Install-ChocolateyInstallPackage".</S><S S="verbose">Экспорт функции "Install-ChocolateyPackage".</S><S S="verbose">Экспорт функции "Install-ChocolateyPath".</S><S S="verbose">Экспорт функции "Install-ChocolateyPinnedTaskBarItem".</S><S S="verbose">Экспорт функции "Install-ChocolateyPowershellCommand".</S><S S="verbose">Экспорт функции "Install-ChocolateyShortcut".</S><S S="verbose">Экспорт функции "Install-ChocolateyVsixPackage".</S><S S="verbose">Экспорт функции "Install-ChocolateyZipPackage".</S><S S="verbose">Экспорт функции "Install-Vsix".</S><S S="verbose">Экспорт функции "Set-EnvironmentVariable".</S><S S="verbose">Экспорт функции "Set-PowerShellExitCode".</S><S S="verbose">Экспорт функции "Start-ChocolateyProcessAsAdmin".</S><S S="verbose">Экспорт функции "Test-ProcessAdminRights".</S><S S="verbose">Экспорт функции "Uninstall-BinFile".</S><S S="verbose">Экспорт функции "Uninstall-ChocolateyEnvironmentVariable".</S><S S="verbose">Экспорт функции "Uninstall-ChocolateyPackage".</S><S S="verbose">Экспорт функции "Uninstall-ChocolateyZipPackage".</S><S S="verbose">Экспорт функции "Update-SessionEnvironment".</S><S S="verbose">Экспорт функции "Write-ChocolateyFailure".</S><S S="verbose">Экспорт функции "Write-ChocolateySuccess".</S><S S="verbose">Экспорт функции "Write-FileUpdateLog".</S><S S="verbose">Экспорт псевдонима "Get-ProcessorBits".</S><S S="verbose">Экспорт псевдонима "Get-InstallRegistryKey".</S><S S="verbose">Экспорт псевдонима "Generate-BinFile".</S><S S="verbose">Экспорт псевдонима "Add-BinFile".</S><S S="verbose">Экспорт псевдонима "Remove-BinFile".</S><S S="verbose">Экспорт псевдонима "refreshenv".</S><S S="verbose">Импорт функции "Format-FileSize".</S><S S="verbose">Импорт функции "Get-ChecksumValid".</S><S S="verbose">Импорт функции "Get-ChocolateyUnzip".</S><S S="verbose">Импорт функции "Get-ChocolateyWebFile".</S><S S="verbose">Импорт функции "Get-EnvironmentVariable".</S><S S="verbose">Импорт функции "Get-EnvironmentVariableNames".</S><S S="verbose">Импорт функции "Get-FtpFile".</S><S S="verbose">Импорт функции "Get-OSArchitectureWidth".</S><S S="verbose">Импорт функции "Get-ToolsLocation".</S><S S="verbose">Импорт функции "Get-UACEnabled".</S><S S="verbose">Импорт функции "Get-UninstallRegistryKey".</S><S S="verbose">Импорт функции "Get-VirusCheckValid".</S><S S="verbose">Импорт функции "Get-WebFile".</S><S S="verbose">Импорт функции "Get-WebFileName".</S><S S="verbose">Импорт функции "Get-WebHeaders".</S><S S="verbose">Импорт функции "Install-BinFile".</S><S S="verbose">Импорт функции "Install-ChocolateyDesktopLink".</S><S S="verbose">Импорт функции "Install-ChocolateyEnvironmentVariable".</S><S S="verbose">Импорт функции "Install-ChocolateyExplorerMenuItem".</S><S S="verbose">Импорт функции "Install-ChocolateyFileAssociation".</S><S S="verbose">Импорт функции "Install-ChocolateyInstallPackage".</S><S S="verbose">Импорт функции "Install-ChocolateyPackage".</S><S S="verbose">Импорт функции "Install-ChocolateyPath".</S><S S="verbose">Импорт функции "Install-ChocolateyPinnedTaskBarItem".</S><S S="verbose">Импорт функции "Install-ChocolateyPowershellCommand".</S><S S="verbose">Импорт функции "Install-ChocolateyShortcut".</S><S S="verbose">Импорт функции "Install-ChocolateyVsixPackage".</S><S S="verbose">Импорт функции "Install-ChocolateyZipPackage".</S><S S="verbose">Импорт функции "Install-Vsix".</S><S S="verbose">Импорт функции "Set-EnvironmentVariable".</S><S S="verbose">Импорт функции "Set-PowerShellExitCode".</S><S S="verbose">Импорт функции "Start-ChocolateyProcessAsAdmin".</S><S S="verbose">Импорт функции "Test-ProcessAdminRights".</S><S S="verbose">Импорт функции "Uninstall-BinFile".</S><S S="verbose">Импорт функции "Uninstall-ChocolateyEnvironmentVariable".</S><S S="verbose">Импорт функции "Uninstall-ChocolateyPackage".</S><S S="verbose">Импорт функции "Uninstall-ChocolateyZipPackage".</S><S S="verbose">Импорт функции "Update-SessionEnvironment".</S><S S="verbose">Импорт функции "Write-ChocolateyFailure".</S><S S="verbose">Импорт функции "Write-ChocolateySuccess".</S><S S="verbose">Импорт функции "Write-FileUpdateLog".</S><S S="verbose">Импорт псевдонима "Add-BinFile".</S><S S="verbose">Импорт псевдонима "Generate-BinFile".</S><S S="verbose">Импорт псевдонима "Get-InstallRegistryKey".</S><S S="verbose">Импорт псевдонима "Get-ProcessorBits".</S><S S="verbose">Импорт псевдонима "refreshenv".</S><S S="verbose">Импорт псевдонима "Remove-BinFile".</S></Objs>

What is Expected?

May be $null = import-module... in Start-ChocolateyProcessAsAdmin? Import-Module return imported object: https://technet.microsoft.com/en-us/library/hh849725.aspx

@ferventcoder
Copy link
Member

Out of curiosity, can you possibly translate the errors you are seeing? Would save me a step.

@sergey-s-betke
Copy link
Author

https://ci.appveyor.com/project/sergey-s-betke/font-gost2-304-81/build/0.8.0-extract-makeutils.150.build.217
log time at 00:08:58

There is import-module return value. I think, code in Start-ChocolateyProcessAsAdmin

$exeToRun = "$($env:SystemRoot)\System32\WindowsPowerShell\v1.0\powershell.exe"
$importChocolateyHelpers = ""
Get-ChildItem "$helpersPath" -Filter *.psm1 | ForEach-Object { $importChocolateyHelpers = "& import-module -name  `'$($_.FullName)`';$importChocolateyHelpers" };
$block = ...

must be changed to

$exeToRun = "$($env:SystemRoot)\System32\WindowsPowerShell\v1.0\powershell.exe"
$importChocolateyHelpers = ""
Get-ChildItem "$helpersPath" -Filter *.psm1 | ForEach-Object { $importChocolateyHelpers = "import-module -name  `'$($_.FullName)`' | Out-Null; $importChocolateyHelpers" };
$block = ...

or

$exeToRun = "$($env:SystemRoot)\System32\WindowsPowerShell\v1.0\powershell.exe"
$importChocolateyHelpers = ""
Get-ChildItem "$helpersPath" -Filter *.psm1 | ForEach-Object { $importChocolateyHelpers = "`$null = import-module -name  `'$($_.FullName)`'; $importChocolateyHelpers" };
$block = ...

@sergey-s-betke
Copy link
Author

@ferventcoder
Copy link
Member

I understand now. Remove the logging of the import module when done in that method. Added to backlog as an enhancement.

@sergey-s-betke
Copy link
Author

sergey-s-betke commented Aug 11, 2016

No, @ferventcoder , it is error, not enhancement. Now choco install --failonstderr FAILED, when Start-ChocolateyProcessAsAdmin used...

@ferventcoder
Copy link
Member

This is breaking the package then? Ah, I didn't catch that from above.

@ferventcoder ferventcoder changed the title Start-ChocolateyProcessAsAdmin Start-ChocolateyProcessAsAdmin Module Import for PowerShell causes errors. Aug 11, 2016
@ferventcoder ferventcoder changed the title Start-ChocolateyProcessAsAdmin Module Import for PowerShell causes errors. Start-ChocolateyProcessAsAdmin Module Import for PowerShell causes errors Aug 11, 2016
@ferventcoder
Copy link
Member

I suggest not using FailOnStdErr - that is there to give you time to move off of the dependency of using it. 0.9.8.x didn't fail on stderr, only 0.9.9.x. We fixed the bug for 0.9.10.x+.

@sergey-s-betke
Copy link
Author

Ok. Thank for Your attention.

@ferventcoder
Copy link
Member

I did earmark this for vNext though so we don't show that output, as that could be annoying.

@ferventcoder
Copy link
Member

This is fixed for 0.10.1

@sergey-s-betke
Copy link
Author

Thank You!

ferventcoder added a commit that referenced this issue Aug 17, 2016
Do not log the output of importing the helpers when running
PowerShell in Start-ChocolateyProcessAsAdmin.
ferventcoder added a commit that referenced this issue Aug 17, 2016
* stable:
  (GH-901) Do not log output for module import
  (maint) use uncompressed 7z.exe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants