chocolatey / boxstarter

Repeatable, reboot resilient windows environment installations made easy using Chocolatey packages
https://boxstarter.org/
Apache License 2.0
1.31k stars 162 forks source link

Boxstarter errors with 'Chocolatey reported an unsuccessful exit code of 1.' while chocolatey install doesn't indicate error. #160

Closed JorritSalverda closed 8 years ago

JorritSalverda commented 8 years ago

When running the following boxstarter script it fails with 'Chocolatey reported an unsuccessful exit code of 1.'. When leaving out the git clone it works without errors though, so it's unlikely there's a chocolatey error.

When inspecting $LastExitCode directly after the git clone it returns 0, even without the || exit 0 in the command.

  $ErrorActionPreference = "Stop"

  trap
  {
    Write-Error $_
    exit 1
  }

  . c:\functions.ps1

  # install git
  cinst git.install -version 2.7.4 -params '"/GitAndUnixToolsOnPath"'

  # reload path
  $env:Path = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine)

  # add deployment keys
  $id_rsa = @"
  -----BEGIN RSA PRIVATE KEY-----
  ***
  -----END RSA PRIVATE KEY-----
  "@

  $id_rsa_pub = @"
  ***
  "@

  $config = @"
  UserKnownHostsFile=/dev/null
     CheckHostIP=no
     StrictHostKeyChecking=no
  "@

  New-Item -ItemType Directory -Force -Path $env:USERPROFILE\.ssh

  [System.IO.File]::WriteAllLines("${env:USERPROFILE}\.ssh\id_rsa", $id_rsa)
  [System.IO.File]::WriteAllLines("${env:USERPROFILE}\.ssh\id_rsa.pub", $id_rsa_pub)
  [System.IO.File]::WriteAllLines("${env:USERPROFILE}\.ssh\config", $config)

  # set sensible git defaults
  ExecCommand "git config --global core.preloadindex true"
  ExecCommand "git config --global core.fscache true"
  ExecCommand "git config --global gc.auto 256"

  # clone inrule catalogs
  ExecCommand "git clone --depth 1 git@bitbucket.org:xivart/**.git c:\some-dir || exit 0"

  # create event log
  [System.Diagnostics.EventLog]::CreateEventSource( "SourceName1", "LogName")
  [System.Diagnostics.EventLog]::CreateEventSource( "SourceName1", "LogName")

ExecCommand does the following.

function ExecCommand
{
  param
  (
    [string] $Command, 
    [bool] $ReturnExitCode = $true
  )

  Log "Running command ${Command}..."

  $output = (cmd /c ${Command})

  if (($ReturnExitCode -eq $true) -and ($LastExitCode -ne 0)) 
  {
    throw "Running command ${Command} failed with exit code $LastExitCode."
  }

  return "$output"
}

I've printed the last 200 lines of the boxstarter.log - the task hangs if I print the full log - but I don't see anything notable in there:

[PACKER-56F9536C]Boxstarter: Installing package c:\packerfile.ps1
[PACKER-56F9536C]Boxstarter: Disabling Automatic Updates from Windows Update
Attempting to build package from 'temp_BoxstarterPackage.nuspec'.
Successfully created package 'temp_BoxstarterPackage.1.0.0.nupkg'
[PACKER-56F9536C]Boxstarter: Created a temporary package temp_BoxstarterPackage from c:\packerfile.ps1 in C:\Users\packeradmin\AppData\Roaming\Boxstarter\BuildPackages
[PACKER-56F9536C]+ Boxstarter starting Calling Chocolatey to install temp_BoxstarterPackage. This may take several minutes to complete...
Installing the following packages:
temp_BoxstarterPackage
By installing you accept licenses for the packages.
15:54:42.799     googlecompute:
temp_BoxstarterPackage v1.0.0 (forced)
[PACKER-56F9536C]+ Boxstarter starting Calling Chocolatey to install git.install. This may take several minutes to complete...
Installing the following packages:
git.install
By installing you accept licenses for the packages.
git.install v2.7.4
Downloading git.install 64 bit
from 'https://github.com/git-for-windows/git/releases/download/v2.7.4.windows.1/Git-2.7.4-64-bit.exe'
[PACKER-56F9536C]Boxstarter: Expanded splat to -validExitCodes @(0) -packageName "git.install" -fileType "exe" -silentArgs "/VERYSILENT /NORESTART /NOCANCEL /SP- /COMPONENTS="icons,icons\quicklaunch,ext,ext\shellhere,ext\guihere,assoc,assoc_sh" /LOG" -file "C:\Users\PACKER~1\AppData\Local\Temp\chocolatey\git.install\2.7.4\git.installInstall.exe"
Installing git.install...
git.install has been installed.
Cloning into 'c:\some-dir'...
PATH environment variable does not have C:\Program Files\Git\cmd in it. Adding...
WARNING: Git installed - You may need to close and reopen your shell for PATH
changes to take effect.
The install of git.install was successful.
Chocolatey installed 1/1 package(s). 0 package(s) failed.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
[PACKER-56F9536C]+ Boxstarter finished Calling Chocolatey to install git.install. This may take several minutes to complete... 00:00:30.5032265
c:\Program Files (x86)\Windows Resource Kits\Tools\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin;C:\Program Files\Google\Compute Engine\sysprep\;C:\Program Files\Google\Compute Engine\metadata_scripts\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;
Directory: C:\Users\packeradmin
Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----        03/28/2016     15:55            .ssh
[PACKER-56F9536C]Boxstarter: Running command git config --global core.preloadindex true...
[PACKER-56F9536C]Boxstarter: Running command git config --global core.fscache true...
[PACKER-56F9536C]Boxstarter: Running command git config --global gc.auto 256...
[PACKER-56F9536C]Boxstarter: Running command git clone --depth 1 git@bitbucket.org:user/some-repo.git c:\some-dir...
Warning: Permanently added 'bitbucket.org' (RSA) to the list of known hosts.
New-Item -Path $installKey | Out-Null
}
if ($gitCmdOnly) {
# update registry so installer picks it up automatically
New-ItemProperty $installKey -Name "Inno Setup CodeFile: Path Option" -Value "Cmd" -PropertyType "String" -Force | Out-Null
The install of temp_boxstarterpackage was NOT successful.
}
Error while running 'C:\ProgramData\chocolatey\lib\temp_BoxstarterPackage\tools\ChocolateyInstall.ps1'.
See log for details.
if ($unixTools) {
# update registry so installer picks it up automatically
New-ItemProperty $installKey -Name "Inno Setup CodeFile: Path Option" -Value "CmdTools" -PropertyType "String" -Force | Out-Null
}
if ($noAutoCrlf) {
# update registry so installer picks it up automatically
New-ItemProperty $installKey -Name "Inno Setup CodeFile: CRLF Option" -Value "CRLFCommitAsIs" -PropertyType "String" -Force | Out-Null
}
# Make our install work properly when running under SYSTEM account (Chef Cliet Service, Puppet Service, etc)
# Add other items to this if block or use $IsRunningUnderSystemAccount to adjust existing logic that needs changing
$IsRunningUnderSystemAccount = ([System.Security.Principal.WindowsIdentity]::GetCurrent()).IsSystem
If ($IsRunningUnderSystemAccount)
{
#strip out quicklaunch parameter as it causes a hang under SYSTEM account
$fileArgs = $fileArgs.replace('icons\quicklaunch,','')
If ($fileArgs -inotlike "*/SUPPRESSMSGBOXES*")
{
$fileArgs = $fileArgs + ' /SUPPRESSMSGBOXES'
}
}
If ([bool](get-process ssh-agent -ErrorAction SilentlyContinue))
{
Write-Output "Killing any git ssh-agent instances for install."
(get-process ssh-agent | where {$_.Path -ilike "*\git\usr\bin\*"}) | stop-process
}
Install-ChocolateyPackage $packageId $fileType $fileArgs $url $url64
if (Test-Path $installKey) {
$keyNames = Get-ItemProperty -Path $installKey
if ($gitCmdOnly -eq $false -and $unixTools -eq $false) {
$installLocation = $keyNames.InstallLocation
if ($installLocation -ne '') {
$gitPath = Join-Path $installLocation 'cmd'
Install-ChocolateyPath $gitPath 'Machine'
}
}
}
Write-Warning "Git installed - You may need to close and reopen your shell for PATH changes to take effect."
Calling command ['"C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -NoLogo -ExecutionPolicy Bypass -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1';& Import-Module 'C:\Users\packeradmin\AppData\Roaming\Boxstarter\Boxstarter.chocolatey\Boxstarter.chocolatey.psd1' -DisableNameChecking -ArgumentList $true; & 'C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1' -packageScript 'C:\ProgramData\chocolatey\lib\git.install\tools\chocolateyInstall.ps1' -installArguments '' -packageParameters ''"']
[2016-03-28T15:54:47.9329605+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Importing Boxstarter vars into pid 1956 from pid: 1860
[2016-03-28T15:54:47.9798304+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Importing BEX.Boxstarter.BaseDir from 1860 to 1956 with value C:\Users\packeradmin\AppData\Roaming\Boxstarter
[2016-03-28T15:54:47.9954668+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Importing BEX.Boxstarter.DisableRestart from 1860 to 1956 with value True
[2016-03-28T15:54:47.9954668+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Importing BEX.Boxstarter.IsRebooting from 1860 to 1956 with value False
[2016-03-28T15:54:47.9954668+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Importing BEX.Boxstarter.LocalRepo from 1860 to 1956 with value C:\Users\packeradmin\AppData\Roaming\Boxstarter\BuildPackages
[2016-03-28T15:54:48.0110825+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Importing BEX.Boxstarter.Log from 1860 to 1956 with value C:\Users\packeradmin\AppData\Local\Boxstarter\boxstarter.log
[2016-03-28T15:54:48.0110825+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Importing BEX.Boxstarter.NoPassword from 1860 to 1956 with value True
[2016-03-28T15:54:48.0110825+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Importing BEX.Boxstarter.NugetSources from 1860 to 1956 with value http://chocolatey.org/api/v2;http://www.myget.org/F/boxstarter/api/v2
[2016-03-28T15:54:48.0110825+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Importing BEX.Boxstarter.Package from 1860 to 1956 with value temp_BoxstarterPackage
[2016-03-28T15:54:48.0110825+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Importing BEX.Boxstarter.ProgramFiles86 from 1860 to 1956 with value C:\Program Files (x86)
[2016-03-28T15:54:48.0267052+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Importing BEX.Boxstarter.RebootOk from 1860 to 1956 with value False
[2016-03-28T15:54:48.0267052+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Importing BEX.Boxstarter.ScriptToCall from 1860 to 1956 with value Import-Module (Join-Path "C:\Users\packeradmin\AppData\Roaming\Boxstarter" BoxStarter.Chocolatey\Boxstarter.Chocolatey.psd1) -global -DisableNameChecking;
Invoke-ChocolateyBoxstarter -bootstrapPackage 'c:\packerfile.ps1'   -DisableReboots
[2016-03-28T15:54:48.0267052+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Importing BEX.Boxstarter.SourcePID from 1860 to 1956 with value 1944
[2016-03-28T15:54:48.0267052+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Importing BEX.Boxstarter.SuppressLogging from 1860 to 1956 with value False
[2016-03-28T15:54:49.3079472+00:00:::PID 1956] Downloading git.install 64 bit
from 'https://github.com/git-for-windows/git/releases/download/v2.7.4.windows.1/Git-2.7.4-64-bit.exe'
Downloading git.install 64 bit
Downloading git.install 64 bit
from 'https://github.com/git-for-windows/git/releases/download/v2.7.4.windows.1/Git-2.7.4-64-bit.exe'
from 'https://github.com/git-for-windows/git/releases/download/v2.7.4.windows.1/Git-2.7.4-64-bit.exe'
[2016-03-28T15:54:58.4798222+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Checking for other running MSIEXEC installers...
[2016-03-28T15:54:58.5266803+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Expanded splat to -validExitCodes @(0) -packageName "git.install" -fileType "exe" -silentArgs "/VERYSILENT /NORESTART /NOCANCEL /SP- /COMPONENTS="icons,icons\quicklaunch,ext,ext\shellhere,ext\guihere,assoc,assoc_sh" /LOG" -file "C:\Users\PACKER~1\AppData\Local\Temp\chocolatey\git.install\2.7.4\git.installInstall.exe"
[2016-03-28T15:54:58.5266803+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Expanded splat to -validExitCodes @(0) -packageName "git.install" -fileType "exe" -silentArgs "/VERYSILENT /NORESTART /NOCANCEL /SP- /COMPONENTS="icons,icons\quicklaunch,ext,ext\shellhere,ext\guihere,assoc,assoc_sh" /LOG" -file "C:\Users\PACKER~1\AppData\Local\Temp\chocolatey\git.install\2.7.4\git.installInstall.exe"
[PACKER-56F9536C]Boxstarter: Expanded splat to -validExitCodes @(0) -packageName "git.install" -fileType "exe" -silentArgs "/VERYSILENT /NORESTART /NOCANCEL /SP- /COMPONENTS="icons,icons\quicklaunch,ext,ext\shellhere,ext\guihere,assoc,assoc_sh" /LOG" -file "C:\Users\PACKER~1\AppData\Local\Temp\chocolatey\git.install\2.7.4\git.installInstall.exe"
[PACKER-56F9536C]Boxstarter: Expanded splat to -validExitCodes @(0) -packageName "git.install" -fileType "exe" -silentArgs "/VERYSILENT /NORESTART /NOCANCEL /SP- /COMPONENTS="icons,icons\quicklaunch,ext,ext\shellhere,ext\guihere,assoc,assoc_sh" /LOG" -file "C:\Users\PACKER~1\AppData\Local\Temp\chocolatey\git.install\2.7.4\git.installInstall.exe"
[2016-03-28T15:54:58.5579563+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Invoking Import-Module C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1 -Global -DisableNameChecking
Install-ChocolateyInstallPackage -validExitCodes @(0) -packageName "git.install" -fileType "exe" -silentArgs "/VERYSILENT /NORESTART /NOCANCEL /SP- /COMPONENTS="icons,icons\quicklaunch,ext,ext\shellhere,ext\guihere,assoc,assoc_sh" /LOG" -file "C:\Users\PACKER~1\AppData\Local\Temp\chocolatey\git.install\2.7.4\git.installInstall.exe"  in scheduled task
[2016-03-28T15:54:58.6204397+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Found 0 tasks already running
[2016-03-28T15:54:58.6360630+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Launched task. Waiting for task to launch command...
[2016-03-28T15:55:00.7141793+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Command launched in process 2056
[2016-03-28T15:55:00.7298188+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Waiting on 2056
[2016-03-28T15:55:00.7766866+00:00:::PID 1956] Installing git.install...
Installing git.install...
Installing git.install...
[2016-03-28T15:55:00.8860724+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.exe 7221248
[2016-03-28T15:55:00.9173122+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.tmp 147881984
[2016-03-28T15:55:00.9485602+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory read: 317427712
[2016-03-28T15:55:00.9485602+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory count: 0
[2016-03-28T15:55:01.9954438+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.exe 7221248
[2016-03-28T15:55:02.0423192+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.tmp 147881984
[2016-03-28T15:55:02.0735780+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory read: 317427712
[2016-03-28T15:55:02.0735780+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory count: 1
[2016-03-28T15:55:03.1048173+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.exe 7221248
[2016-03-28T15:55:03.1673099+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.tmp 155660288
[2016-03-28T15:55:03.1985644+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory read: 332984320
[2016-03-28T15:55:03.1985644+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory count: 2
[2016-03-28T15:55:04.2610597+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.exe 7221248
[2016-03-28T15:55:04.2923095+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.tmp 155680768
[2016-03-28T15:55:04.3079394+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory read: 333025280
[2016-03-28T15:55:04.3079394+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory count: 0
[2016-03-28T15:55:05.3235515+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.exe 7221248
[2016-03-28T15:55:05.3391967+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.tmp 155762688
[2016-03-28T15:55:05.3704368+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory read: 333189120
[2016-03-28T15:55:05.3704368+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory count: 1
[2016-03-28T15:55:06.3860698+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.exe 7221248
[2016-03-28T15:55:06.4017019+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.tmp 155926528
[2016-03-28T15:55:06.4329397+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory read: 333516800
[2016-03-28T15:55:06.4329397+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory count: 0
[2016-03-28T15:55:07.4485721+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.exe 7221248
[2016-03-28T15:55:07.4641973+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.tmp 156143616
[2016-03-28T15:55:07.4954396+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory read: 333950976
[2016-03-28T15:55:07.4954396+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory count: 1
[2016-03-28T15:55:08.5110625+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.exe 7221248
[2016-03-28T15:55:08.5423124+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.tmp 156340224
[2016-03-28T15:55:08.5579373+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory read: 334344192
[2016-03-28T15:55:08.5579373+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory count: 0
[2016-03-28T15:55:09.5735841+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.exe 7221248
[2016-03-28T15:55:09.6204512+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.tmp 157982720
[2016-03-28T15:55:09.6516950+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory read: 337629184
[2016-03-28T15:55:09.6516950+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory count: 1
[2016-03-28T15:55:10.6673116+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.exe 7221248
[2016-03-28T15:55:10.6985593+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.tmp 158154752
[2016-03-28T15:55:10.7141930+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory read: 337973248
[2016-03-28T15:55:10.7141930+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory count: 0
[2016-03-28T15:55:11.7454405+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.exe 7221248
[2016-03-28T15:55:11.7766792+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: git.installInstall.tmp 158523392
[2016-03-28T15:55:11.8079424+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory read: 338710528
[2016-03-28T15:55:11.8235650+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Memory count: 1
[2016-03-28T15:55:13.8235810+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Proc has exited: True or Is Null: False
[2016-03-28T15:55:13.8235810+00:00:::PID 1956] git.install has been installed.
git.install has been installed.
git.install has been installed.
[2016-03-28T15:55:13.8704484+00:00:::PID 1956] [PACKER-56F9536C]Boxstarter: Task has completed
[2016-03-28T15:55:13.9173266+00:00:::PID 1956] PATH environment variable does not have C:\Program Files\Git\cmd in it. Adding...
PATH environment variable does not have C:\Program Files\Git\cmd in it. Adding...
PATH environment variable does not have C:\Program Files\Git\cmd in it. Adding...
WARNING: Git installed - You may need to close and reopen your shell for PATH
WARNING: Git installed - You may need to close and reopen your shell for PATH
changes to take effect.
changes to take effect.
Command ['"C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -NoLogo -ExecutionPolicy Bypass -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1';& Import-Module 'C:\Users\packeradmin\AppData\Roaming\Boxstarter\Boxstarter.chocolatey\Boxstarter.chocolatey.psd1' -DisableNameChecking -ArgumentList $true; & 'C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1' -packageScript 'C:\ProgramData\chocolatey\lib\git.install\tools\chocolateyInstall.ps1' -installArguments '' -packageParameters ''"'] exited with '0'
Calling command ['"shutdown" /a']
Command ['"shutdown" /a'] exited with '1116'
Capturing package files in 'C:\ProgramData\chocolatey\lib\git.install'
Found 'C:\ProgramData\chocolatey\lib\git.install\git.install.nupkg'
with checksum 'CE82B4939686628562172212157E0C7A'
Found 'C:\ProgramData\chocolatey\lib\git.install\tools\chocolateyInstall.ps1'
with checksum 'F9D326B69D7E06EE6F32AEB4544471B2'
Attempting to create directory "C:\ProgramData\chocolatey\.chocolatey\git.install.2.7.4".
Attempting to copy "C:\ProgramData\chocolatey\.chocolatey\git.install.2.7.4\.registry.update"
to "C:\ProgramData\chocolatey\.chocolatey\git.install.2.7.4\.registry".
Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\git.install.2.7.4\.registry.update".
Attempting to copy "C:\ProgramData\chocolatey\.chocolatey\git.install.2.7.4\.files.update"
to "C:\ProgramData\chocolatey\.chocolatey\git.install.2.7.4\.files".
Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\git.install.2.7.4\.files.update".
Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\git.install.2.7.4\.sxs".
Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\git.install.2.7.4\.pin".
The install of git.install was successful.
The install of git.install was successful.
Chocolatey installed 1/1 package(s). 0 package(s) failed.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
Chocolatey installed 1/1 package(s). 0 package(s) failed.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
[2016-03-28T15:55:14.0891891+00:00:::PID 1860] [PACKER-56F9536C]Boxstarter: restoring current directory location to C:\Users\packeradmin\AppData\Roaming\Boxstarter\boxstarter.chocolatey\chocolatey
[2016-03-28T15:55:14.1048264+00:00:::PID 1860] [PACKER-56F9536C]Boxstarter: Exit Code: 0
[2016-03-28T15:55:14.1673303+00:00:::PID 1860] [PACKER-56F9536C]+ Boxstarter finished Calling Chocolatey to install git.install. This may take several minutes to complete... 00:00:30.5032265
[2016-03-28T15:55:14.1673303+00:00:::PID 1860] [PACKER-56F9536C]+ Boxstarter finished Calling Chocolatey to install git.install. This may take several minutes to complete... 00:00:30.5032265
[PACKER-56F9536C]+ Boxstarter finished Calling Chocolatey to install git.install. This may take several minutes to complete... 00:00:30.5032265
c:\Program Files (x86)\Windows Resource Kits\Tools\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin;C:\Program Files\Google\Compute Engine\sysprep\;C:\Program Files\Google\Compute Engine\metadata_scripts\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;
Directory: C:\Users\packeradmin
Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----        03/28/2016     15:55            .ssh
[2016-03-28T15:55:14.2454304+00:00:::PID 1860] [PACKER-56F9536C]Boxstarter: Running command git clone --depth 1 git@bitbucket.org:user/some-repo.git c:\some-dir...
[2016-03-28T15:55:14.2454304+00:00:::PID 1860] [PACKER-56F9536C]Boxstarter: Running command git clone --depth 1 git@bitbucket.org:user/some-repo.git c:\some-dir...
[PACKER-56F9536C]Boxstarter: Running command git clone --depth 1 git@bitbucket.org:user/some-repo.git c:\some-dir...
Cloning into 'c:\some-dir'...
Warning: Permanently added 'bitbucket.org' (RSA) to the list of known hosts.
[2016-03-28T15:55:22.0579434+00:00:::PID 1860] [PACKER-56F9536C]Boxstarter: Running command dir c:\some-dir...
[2016-03-28T15:55:22.0579434+00:00:::PID 1860] [PACKER-56F9536C]Boxstarter: Running command dir c:\some-dir...
[2016-03-28T15:55:22.1673328+00:00:::PID 1860] [PACKER-56F9536C]Boxstarter: Running command git config --global core.preloadindex true...
[2016-03-28T15:55:22.1673328+00:00:::PID 1860] [PACKER-56F9536C]Boxstarter: Running command git config --global core.preloadindex true...
[2016-03-28T15:55:22.2142099+00:00:::PID 1860] [PACKER-56F9536C]Boxstarter: Running command git config --global core.fscache true...
[2016-03-28T15:55:22.2142099+00:00:::PID 1860] [PACKER-56F9536C]Boxstarter: Running command git config --global core.fscache true...
[2016-03-28T15:55:22.2766845+00:00:::PID 1860] [PACKER-56F9536C]Boxstarter: Running command git config --global gc.auto 256...
[2016-03-28T15:55:22.2766845+00:00:::PID 1860] [PACKER-56F9536C]Boxstarter: Running command git config --global gc.auto 256...
15:55:24.524     googlecompute:
Failures:
- temp_boxstarterpackage
Chocolatey : Chocolatey reported an unsuccessful exit code of 1. See
C:\Users\packeradmin\AppData\Local\Boxstarter\boxstarter.log for details.
Chocolatey installed 0/1 package(s). 1 package(s) failed.
At C:\Users\packeradmin\AppData\Roaming\Boxstarter\Boxstarter.Chocolatey\Invoke
-ChocolateyBoxstarter.ps1:200 char:5
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
[PACKER-56F9536C]+ Boxstarter finished Calling Chocolatey to install temp_BoxstarterPackage. This may take several minutes to complete... 00:00:43.1793286
[PACKER-56F9536C]Boxstarter: Restore Automatic Updates from Windows Update
True
15:55:24.533     googlecompute:
15:55:24.534     googlecompute:
Errors       : {Chocolatey reported an unsuccessful exit code of 1. See C:\Users\packeradmin\AppData\Local\Boxstarter\boxstarter.log for details.}
ComputerName : localhost
Completed    : True
FinishTime   : 3/28/2016 3:55:24 PM
StartTime    : 3/28/2016 3:54:39 PM

All this runs from a packer job. Is there anything you can think of that can cause this?

mwrock commented 8 years ago

All custom Powershell is run from a chocolatey package and if chocolatey captures an error, it will fail and emit an exit code of 1. Some things to try to troubleshoot:

I'm assuming this is a private repo? Otherwise I'd use https instead of ssh.

JorritSalverda commented 8 years ago

That didn't help, neither does wrapping the git clone in a try/catch.

Could it be that is uses too much memory? I use this to set the max memory:

winrm set winrm/config/winrs @{MaxMemoryPerShellMB=\"4096\"}

mwrock commented 8 years ago

depends on where in the packer build you are doing this. If you are running it from a packer provisioner it is possible since that runs under winrm. Not at all likely if you are running it from the initial boot.

However if that was the case, I'd expect a OutOfMemoryException which you would see if you captured the error in a try/catch and wrote out the error message.

JorritSalverda commented 8 years ago

I've managed to work around it by moving the git clone out of the boxstarter package but still in the packer build. A consecutive git pull gave the same issue, so keeping it outside of the boxstarter package as well. I might give it another try in the future, but it already cost me a week so perhaps there's better stuff to do :)