Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Blocker
-
Resolution: Fixed
-
Affects Version/s: 0.10.6
-
Fix Version/s: 0.10.8
-
Component/s: Chef Client, Chef Solo
-
Labels:
-
Environment:
Windows
Description
Chef::ShellOut::Windows is exhibiting multiple issues in 0.10.6:
- not doing smart resolution of any file with an extension in PATHEXT (ie .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.RB;.RBW)...this causes failures in the following code (Chef::Provider::Package::Rubygems uses shell_out under the covers):
gem_package "chef" do version node['omnibus']['chef-client']['version'] gem_binary "#{embedded_dir}\\bin\\gem" options "-n '#{node['omnibus']['chef-client']['home']}\\bin' --no-rdoc --no-ri" end
In this case "C:\opscode\chef\embedded\bin\gem" is actually "C:\opscode\chef\embedded\bin\gem.bat".
- .bat files are not executed correctly. From the CreatProcess API doc: To run a batch file, you must start the command interpreter; set lpApplicationName to cmd.exe and set lpCommandLine to the following arguments: /c plus the name of the batch file.
- STDIN/STDOUT redirection issues with certain programs (ie xcopy) when run under CreateProcess. thus the following code fails silently on the second command:
windows_batch "unzip_and_move_ruby" do code <<-EOH "#{node['7-zip']['home']}\\7z.exe" x #{ruby_download_path} -o#{file_cache_path} -r -y xcopy \"#{unzip_dir_name}\" \"#{embedded_dir}\" /e /y EOH action :run not_if { ::File.exists?("#{embedded_dir}/bin/ruby.exe") } end
The fix for this bug appears to redirect STDIN if you redirect STDOUT.
This fix should be rolled into mixlib-shellout also as the code now lives there.
This has been fixed in chef/0.10.6-rc:
https://github.com/opscode/chef/commit/1033f0ba6aab441ffe13ffeb36b3c28881266344