Skip to content

Instantly share code, notes, and snippets.

@bbrala
Last active May 9, 2018 06:08
Show Gist options
  • Save bbrala/7e96be8a4e26f14834e8bbc21d246c38 to your computer and use it in GitHub Desktop.
Save bbrala/7e96be8a4e26f14834e8bbc21d246c38 to your computer and use it in GitHub Desktop.
How to run development version of vagrant on windows.
:ssl_verify_mode: 0
@echo off
PATH %PATH%;C:\HashiCorp\Vagrant\embedded\bin;C:\HashiCorp\Vagrant\embedded\gnuwin32\bin;C:\HashiCorp\Vagrant\embedded\mingw64\bin;
ruby c:\vagrant\exec\vagrant %*

These are the steps to install a dev version of Vagrant on your Windows machine. It does assume you also have normal Vagrant installed on the default location, since it needs the packages binaries of a few libraries to work completely. Normal path would be C:\HashiCorp\Vagrant.

At the moment the version of Ruby / Bundler used has a bug which results in the following error SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed. See stackoverflow for a solution.

  • Easiest fix for now is to create a .gemrc file in your %USERPROFILE% with the following content: :ssl_verify_mode: 0.

Next up, getting Vagrant running from source. Their documentation is mostly correct. ( https://www.vagrantup.com/docs/installation/source.html#install-ruby )

  • Clone vagrant git clone https://github.com/mitchellh/vagrant.git ( for this document i assume the path will be c:\vagrant )
  • Check vagrant.gemspec for the specific version of bundler you need. And install that version (currently 1.12.5).
  • gem install bundler -v '1.12.5'

Now we will install the vagrant bundle

  • cd vagrant Enter the directory you cloned Vagrant to
  • bundle install Install the bundle
  • bundle --binstubs exec Create an executable file to use vagrant anywhere

In order to run vagrant you need a few directories added to your path. You can either do this globally in system settings, or just use a batch file to set them when you run Vagrant from source.

I use a batch file copies to %USERPROFILE% (c:\users\[my username]\) so i can just run the dev version of Vagrant in my console by typing vagrant-dev.

To load plugins you need to edit the Gemfile in the root of the vagrant repository. Just add the following code with the correct plugins. After editing the file, run bundle install and it will install the plugins.

source "https://rubygems.org"

gemspec

if File.exist?(File.expand_path("../../vagrant-spec", __FILE__))
  gem 'vagrant-spec', path: "../vagrant-spec"
else
  gem 'vagrant-spec', git: "https://github.com/mitchellh/vagrant-spec.git"
end

group :plugins do
  gem "vagrant-remove-old-box-versions"
  gem "vagrant-reload"
  gem "vagrant-triggers"
  gem "vagrant-vbguest"
  gem "vagrant-hosts-provisioner"
end
@TonyApuzzo
Copy link

TonyApuzzo commented May 8, 2018

Hi, thanks for the instructions!

It turns out that as of May 2018, it is much easier to get this working by using Chocolatey's Ruby and msys2 packages.

First install Chocolatey

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

Then Install Ruby with Ruby Dev Kit

cinst ruby                        # install ruby
cinst msys2 --params "/NoUpdate"  # install msys2 without system update
Update-SessionEnvironment         # refresh environment vars
ridk install 2 3                  # use ruby's ridk to update the system and install development toolchain

Then Install bundler, vagrant and set it up as you describe:

git clone https://github.com/mitchellh/vagrant.git
gem install bundler
cd vagrant
vim Gemfile    # Add any needed plugins
bundle install
bundle --binstubs exec

Plugin install went perfectly when I updated the Gemfile as you described.

Note that I didn't have to specify version numbers to get things working, nor did I need to override the SSL settings.

@bbrala
Copy link
Author

bbrala commented May 9, 2018

Thanks for the help, that seems like a lot less effort :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment