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

Make Vagrant binary a parameter #218

Closed
bheuvel opened this issue Mar 25, 2016 · 1 comment
Closed

Make Vagrant binary a parameter #218

bheuvel opened this issue Mar 25, 2016 · 1 comment

Comments

@bheuvel
Copy link
Contributor

bheuvel commented Mar 25, 2016

If I'm going wrong about this, please let me know (how otherwise).

tl;dr the proposed PR #219 solves my problem, basically enables running Vagrant from master (in/from kitchen off course 😉) on Windows.

Problem:
Due to dependencies I was forced to upgrade to Vagrant >= 1.8.
Vagrant 1.8 (msi/installer) introduces Ruby 2.2, which does not support the (msi) bundled Nokogiri, thereby making Vagrant >= 1.8 inoperable for me
This has been fixed on master (details: hashicorp/vagrant#6848)

Solution attempt 1, bundle
Including Vagrant (master) in my bundler config (gem via github)
Fail
This does not work as kitchen calls vagrant using Mixlib::ShellOut: https://github.com/test-kitchen/test-kitchen/blob/master/lib/kitchen/shell_out.rb#L67
Bundler does not pick this up, resulting in a Vagrant not found error.

Solution attempt 2, binstubs
To use very latest Vagrant master, the wiki explains how to do this: https://github.com/mitchellh/vagrant/wiki/Installing-Vagrant-from-Source#use-dev-version.
Basically Bundler creates a binstub vagrant, which is a ruby file (shebang).
Fail
These shebang files do not work on Windows (cmd/PowerShell). (Just calling the file doesn't work. Calling ruby <vagrant_stub> does work)

Solution attempt 2.1, Cygwin using the binstub
When using Cygwin or mingw, the shebang works, and the latest development version of Vagrant is available when called directly from a bash shell.
Fail
But kitchen-vagrant uses Mixlib::ShellOut, which does not use the shell it originated from but uses Win32API which is somewhat equivalent to the default shell, cmd, where the shebang binstubs don't work.

Solution attempt 2.2, cmd file using the binstub
Considering the fact that the binstubs do work in native Windows when using ruby <full path to the binstub>, I created a vagrant.cmd file with content: ruby c:\dev\vagrant\exec\vagrant %*, and put that in my path.
Thereby from cmd or PowerShell able to use e.g vagrant --version.
Fail
But kitchen-vagrant uses Mixlib::ShellOut, which requires that exact command (vagrant), or command.EXE (vagrant.exe) to exist, and does not pick up vagrant.cmd

Solution attempt 2.2.1, code patch using cmd file using the binstub
To be able to make attempt 2.2 work, I would need to change the kitchen-vagrant code, like follows:
from

self.class.vagrant_version ||= run_silently(
  "vagrant --version", :cwd => Dir.pwd).chomp.split(" ").last

to

self.class.vagrant_version ||= run_silently(
  "vagrant.cmd  --version", :cwd => Dir.pwd).chomp.split(" ").last

Success!

With PR #219, I have made vagrant a parameter, which could be for example vagrant.cmd, but can also be something like ruby c:\dev\vagrant\exec\vagrant (both work).

@bheuvel
Copy link
Contributor Author

bheuvel commented Apr 5, 2016

Implemented with #219

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

2 participants