Shell provisioner hangs on Windows 7
mandarbarve opened this issue · 3 comments
When doing vagrant up on Windows 7 shell provisioner hangs when uploading a temporary file from local machine to the guest VM. File created in the temporary location on the host is not closed before yielding for upload to guest VM path. This appeared to be the reason for upload process hang as the data was transferred but SCP would still not complete which could be because the end of file character was not sent. I made a change in the shell.rb file under embedded\lib\ruby\gems\1.9.1\gems\vagrant-1.0.3\lib\vagrant\provisioners folder. With this change problem went away and I could deploy the guest VM successfully.
Below is the patch for the change made. Please take a look.
--- C:/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/vagrant-1.0.3/lib/vagrant/provisioners/shell.org.rb Tue May 01 23:27:42 2012
+++ C:/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/vagrant-1.0.3/lib/vagrant/provisioners/shell.rb Fri Jul 13 12:08:49 2012
@@ -60,12 +60,13 @@
# and handle it specially...
file = Tempfile.new('vagrant-shell')
begin
file.write(config.inline)
file.fsync
-
file.close yield file.path
-
ensure
-
end
rescue file.close file.unlink end
Clarification of the patch:
- Closed file explicitly before upload
--- C:/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/vagrant-1.0.3/lib/vagrant/provisioners/shell.org.rb Tue May 01 23:27:42 2012
+++ C:/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/vagrant-1.0.3/lib/vagrant/provisioners/shell.rb Fri Jul 13 12:08:49 2012
@@ -60,12 +60,13 @@
# and handle it specially...
file = Tempfile.new('vagrant-shell')
begin
file.write(config.inline)
file.fsync
-
file.close <<<<< Added code to close the file explicitly yield file.path
-
ensure
-
end
rescue <<<< Since the file is closed before yielding for upload, now closing and unlinking only for rescue file.close file.unlink end
The patches in pull request 1182 and 1183 should have resolved this too.
Good to hear, closing!