Skip to content

Instantly share code, notes, and snippets.

@mattolenik
Last active May 1, 2018 20:10
Show Gist options
  • Save mattolenik/472a24907d9181b809bfcf382b7edc7c to your computer and use it in GitHub Desktop.
Save mattolenik/472a24907d9181b809bfcf382b7edc7c to your computer and use it in GitHub Desktop.
Install and use a new gem inside a Vagrantfile
gem_dir = "#{Dir.home}/.vagrant.d/gems/#{RUBY_VERSION}"
begin
name = "inifile"
version = "3.0.0"
Gem::Specification.find_by_name(name, version)
rescue Gem::LoadError
require "rubygems/dependency_installer"
installer = Gem::DependencyInstaller.new(:document => [], :install_dir => gem_dir)
installer.install(name, version)
end
require "#{gem_dir}/gems/#{name}-#{version}/lib/#{name}.rb"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment