Closed gh2k closed 8 years ago
Agree, that is odd. However, the fix in busser-serverspec is ultimately the right way to resolve this--I've had issues getting the RubyGems-build .bat wrapper coming out consistently correctly and the test-kitchen code falls back to using the /path/to/ruby /path/to/ruby/binstub
pattern.
I'll investigate this a little to see if Busser is setting up an incorrect path to Ruby, but otherwise I'm hoping we're okay here.
@cheeseplus It seems https://github.com/test-kitchen/busser/blob/13115a2890583fb3041bf8ed804de4b2d36f6e04/lib/busser/command/setup.rb#L59-L97 is not being written in Window 2012r2 for Chef 11. Instead, the default bat file created by rubygems (https://github.com/rubygems/rubygems/search?utf8=%E2%9C%93&q=goto) is being used. This fails because ruby is not on the path when test-kitchen calls it.
busser.bat file created by rubygems installer:
@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
@"ruby.exe" "C:/Users/vagrant/AppData/Local/Temp/verifier/bin/busser" %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO :EOF
:WinNT
@"ruby.exe" "%~dpn0" %*
@dhoer / @cheeseplus We're seeing the same thing in EC2. Currently, our CI uses chef-client 11.18.6. Although, we use Chef-Client 12 for local development. We cannot yet upgrade to Chef-Client 12 because our Production estate is still using Chef-Client 11.
Is there a way to fix this ? I'm trying to investigate what exactly has changed. Because this worked on the 24th of March.
This seems to reproducible with ChefDK 0.12.0, TK 1.6.0, Chef-Client 11.18.6 Only in AWS EC2.
Here is a snippet of a kitchen test.
-----> Verifying <default-Windows2012>...
Preparing files for transfer
D Creating local sandbox in C:/Users/CHRIST~1.CLA/AppData/Local/Temp/default-Windows2012-sandbox-20160404-33148-vl3r8k
D [WinRM] reusing existing connection negotiate::http://10.103.2.130:5985/wsman<{:user=>"vagrant", :pass=>"vagrant", :no_ssl_peer_verification=>true, :disable_sspi=>false, :basic_auth_only=>false}>
D [WinRM] negotiate::http://10.103.2.130:5985/wsman<{:user=>"vagrant", :pass=>"vagrant", :no_ssl_peer_verification=>true, :disable_sspi=>false, :basic_auth_only=>false}> (
$env:BUSSER_ROOT = "$env:TEMP\verifier"
$env:GEM_HOME = "$env:TEMP\verifier\gems"
$env:GEM_PATH = "$env:TEMP\verifier\gems"
$env:GEM_CACHE = "$env:TEMP\verifier\gems\cache"
$ruby = "$env:systemdrive\opscode\chef\embedded\bin\ruby.exe"
$gem = "$env:systemdrive\opscode\chef\embedded\bin\gem"
$version = "busser"
$gem_install_args = "busser --no-rdoc --no-ri --no-format-executable -n $env:TEMP\verifier\bin --no-user-install"
$busser = "$env:TEMP\verifier\bin\busser.bat"
$plugins = "busser-serverspec"
if ((& "$ruby" "$gem" list busser -i) -ne "true") {
Write-Host "-----> Installing Busser ($version)`n"
& "$ruby" "$gem" install $gem_install_args.Split() 2>&1
} else {
Write-Host "-----> Busser installation detected ($version)`n"
}
if (-Not (Test-Path "$busser")) {
$gem_bindir = & "$ruby" -rrubygems -e "puts Gem.bindir.dup.gsub('/', '\\')"
& "$ruby" "$gem_bindir\busser" setup --type bat 2>&1
}
Write-Host " Installing Busser plugins: $plugins`n"
& "$busser" plugin install $plugins.Split() 2>&1
)
-----> Installing Busser (busser)
Successfully installed thor-0.19.0
Successfully installed busser-0.7.1
2 gems installed
Installing Busser plugins: busser-serverspec
$$$$$$ busser.bat : '"ruby.exe"' is not recognized as an internal or external command,
$$$$$$ At line:26 char:1
$$$$$$ + & "$busser" plugin install $plugins.Split() 2>&1
$$$$$$ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$$$$$$ + CategoryInfo : NotSpecified: ('"ruby.exe"' is...ternal command,
$$$$$$ :String) [], RemoteException
$$$$$$ + FullyQualifiedErrorId : NativeCommandError
$$$$$$
D Cleaning up local sandbox in C:/Users/CHRIST~1.CLA/AppData/Local/Temp/default-Windows2012-sandbox-20160404-33148-vl3r8k
>>>>>> Verify failed on instance <default-Windows2012>.
>>>>>> Please see .kitchen/logs/default-Windows2012.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: WinRM exited (1) for command: [
$env:BUSSER_ROOT = "$env:TEMP\verifier"
$env:GEM_HOME = "$env:TEMP\verifier\gems"
$env:GEM_PATH = "$env:TEMP\verifier\gems"
$env:GEM_CACHE = "$env:TEMP\verifier\gems\cache"
$ruby = "$env:systemdrive\opscode\chef\embedded\bin\ruby.exe"
$gem = "$env:systemdrive\opscode\chef\embedded\bin\gem"
$version = "busser"
$gem_install_args = "busser --no-rdoc --no-ri --no-format-executable -n $env:TEMP\verifier\bin --no-user-install"
$busser = "$env:TEMP\verifier\bin\busser.bat"
$plugins = "busser-serverspec"
if ((& "$ruby" "$gem" list busser -i) -ne "true") {
Write-Host "-----> Installing Busser ($version)`n"
& "$ruby" "$gem" install $gem_install_args.Split() 2>&1
} else {
Write-Host "-----> Busser installation detected ($version)`n"
}
if (-Not (Test-Path "$busser")) {
$gem_bindir = & "$ruby" -rrubygems -e "puts Gem.bindir.dup.gsub('/', '\\')"
& "$ruby" "$gem_bindir\busser" setup --type bat 2>&1
}
Write-Host " Installing Busser plugins: $plugins`n"
& "$busser" plugin install $plugins.Split() 2>&1
]
>>>>>> ----------------------
D Verify failed on instance <default-Windows2012>.
D ------Exception-------
D Class: Kitchen::InstanceFailure
D Message: Verify failed on instance <default-Windows2012>. Please see .kitchen/logs/default-Windows2012.log for more details
D ---Nested Exception---
D Class: Kitchen::ActionFailed
D Message: WinRM exited (1) for command: [
$env:BUSSER_ROOT = "$env:TEMP\verifier"
$env:GEM_HOME = "$env:TEMP\verifier\gems"
$env:GEM_PATH = "$env:TEMP\verifier\gems"
$env:GEM_CACHE = "$env:TEMP\verifier\gems\cache"
$ruby = "$env:systemdrive\opscode\chef\embedded\bin\ruby.exe"
$gem = "$env:systemdrive\opscode\chef\embedded\bin\gem"
$version = "busser"
$gem_install_args = "busser --no-rdoc --no-ri --no-format-executable -n $env:TEMP\verifier\bin --no-user-install"
$busser = "$env:TEMP\verifier\bin\busser.bat"
$plugins = "busser-serverspec"
if ((& "$ruby" "$gem" list busser -i) -ne "true") {
Write-Host "-----> Installing Busser ($version)`n"
& "$ruby" "$gem" install $gem_install_args.Split() 2>&1
} else {
Write-Host "-----> Busser installation detected ($version)`n"
}
if (-Not (Test-Path "$busser")) {
$gem_bindir = & "$ruby" -rrubygems -e "puts Gem.bindir.dup.gsub('/', '\\')"
& "$ruby" "$gem_bindir\busser" setup --type bat 2>&1
}
Write-Host " Installing Busser plugins: $plugins`n"
& "$busser" plugin install $plugins.Split() 2>&1
]
D ------Backtrace-------
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.6.0/lib/kitchen/verifier/base.rb:83:in `rescue in call'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.6.0/lib/kitchen/verifier/base.rb:86:in `call' D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.6.0/lib/kitchen/instance.rb:423:in `block in verify_action'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.6.0/lib/kitchen/instance.rb:513:in `call'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.6.0/lib/kitchen/instance.rb:513:in `synchronize_or_call'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.6.0/lib/kitchen/instance.rb:478:in `block in action'
D C:/opscode/chefdk/embedded/lib/ruby/2.1.0/benchmark.rb:279:in `measure'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.6.0/lib/kitchen/instance.rb:477:in `action'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.6.0/lib/kitchen/instance.rb:415:in `verify_action'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.6.0/lib/kitchen/instance.rb:348:in `block in transition_to'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.6.0/lib/kitchen/instance.rb:347:in `each'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.6.0/lib/kitchen/instance.rb:347:in `transition_to'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.6.0/lib/kitchen/instance.rb:160:in `verify'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.6.0/lib/kitchen/instance.rb:189:in `block in test'
D C:/opscode/chefdk/embedded/lib/ruby/2.1.0/benchmark.rb:279:in `measure'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.6.0/lib/kitchen/instance.rb:185:in `test'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.6.0/lib/kitchen/command.rb:176:in `public_send'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.6.0/lib/kitchen/command.rb:176:in `block (2 levels) in run_action'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/logging-2.1.0/lib/logging/diagnostic_context.rb:450:in `call'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/logging-2.1.0/lib/logging/diagnostic_context.rb:450:in `block in create_with_logging_context'
D ----------------------
D [WinRM] closing remote shell F024F848-44CD-4CD6-AF29-0271037E7A95 on http://10.103.2.130:5985/wsman
D [WinRM] remote shell F024F848-44CD-4CD6-AF29-0271037E7A95 closed
I have submitted a fix for this here: https://github.com/test-kitchen/test-kitchen/pull/1003
Thanks @mwrock! :+1:
I see test-kitchen released v1.7.2 yesterday. When can we expect this patch to be released?
Likely sometime before the next dk this month.
Originally reported at test-kitchen/test-kitchen#616 but re-reporting here as the symptoms of that bug are now fixed, but the cause remains.
On Windows, the batchfile binstubs generated by busser in
%TEMP%\verifier\gems\bin\
do not point at a valid ruby. The ruby.exe that they try to call does not exist on the machine.In my case,
bundle.bat
looks like this:Where
bundle
in the same directory, looks like this:The latter is correct.
This leads to errors when trying to run binaries, even with the correct environment. An example would be running serverspec tests with a Gemfile present (which runs 'bundle'):
Note, this error no longer occurs as it was worked around by test-kitchen/busser-serverspec#27 which calls bundler explicitly via
/path/to/ruby.exe /path/to/bundle/script
instead.