Table of Contents

Vagrant Dev

System Installation

As a bonus you won't need to install bunder nor rubygems since they are included since ruby 1.9

$ \curl -sSL https://get.rvm.io | bash -s stable
$ source ~/.rvm/scripts/rvm
$ rvm requirements
$ rvm install 2.0.0
$ rvm use --default 2.0.0

Compile vagrant gem for dev:

rvm install 1.9.3              # If you haven't installed ruby 1.9.3 yet, do so
rvm use 1.9.3@global           # If you don't already have bundler, install it to the global gemset
gem install bundler
gem install rake
gem install rubygems-bundler   # For automatic bundler support in [RVM](http://rvm.io/integration/bundler#rubygems-bundler)

# Now install vagrant as a gem
git clone git://github.com/mitchellh/vagrant.git && cd vagrant
rvm use 1.9.3@vagrant --create # Create a vagrant gemset to hold the development version + deps (so we don't conflict with any installer version of vagrant)
bundle install
rake                           # run tests (you shouldn't see any failures)
rake install                   # Install development version of vagrant
gem regenerate_binstubs        # Stops vagrant from complaining about "Unresolved specs during Gem::Specification.reset" (We've already installed vagrant's dependencies via bundler!)

bundle install not bundler install

Install RVM:

  gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
  \curl -sSL https://get.rvm.io | bash -s stable
  

Install ruby v2.1.5

  rvm list known
  rvm install 2.1
  
  rvm use 2.1
  
  rvm use 2.1 --default
      

* https://quickleft.com/blog/engineering-lunch-series-step-by-step-guide-to-building-your-first-ruby-gem/

A gem is essentially a Ruby plugin. Before digging into gems though, let's look at some history.

The concept of Ruby plugins actually predates the concept and implementation of Ruby gems. However, plugins of the past required the full code hierarchy to be included directly into your own project, committed to source and all. Updating plugins was a manual process as well, where the updated code would have to be downloaded and extracted atop the previous version in your project. Due to the lack of automation, propensity for mistakes, and potential for developers to modify plugin code as a result of it being included in the code base, this is less than ideal.

Ruby gems makes life much, much easier. Rather than including third party code directly into your application, you just reference the name (and optionally version) of the gem you want to use. Generally speaking, Bundler acts as a package manager by determining the full set of direct dependencies needed by your application, as well as sub-dependencies needed by those first-level dependencies. The code for required gems is still downloaded to your system, but it is kept separate from your application in the sense that it does not have to be maintained in source control. The only aspect of gems that you'll have to manage is the list of names within a special file, known as a Gemfile.

Ruby Gem environment

You’re supposed to run bundle install to install Octopress’s pre-requisites (including a specific version of the Ruby interpreter itself), which will end up in ~/.gem. Bundle’s job is to make setting up an application repeatable, but I was unwittingly playing mix-master with multiple versions of gems and multiple locations Ruby gems could be installed on the file-system.

/usr/share/gems <-- where RPM packages put gems
/usr/local/share/gems <-- where gem(1) puts gems
~/.gem/ruby/1.9.1/gems <-- where bundle puts gems

Gems are install for user scope. When run by root, the files are installed in

  /usr/local/share/gems/gems/bundler-1.8.3/lib/bundler/ui.rb
  /usr/bin
  

Otherwise, they are installed in:

  ~/.gem/ruby/gems
  ~/bin/
  

Set GEM_HOME GEM_PATH

Gem environment

  gem install gem-path

Usage

gem path rails
=> /home/cbliard/.rvm/gems/ruby-2.1.5/gems/rails-4.0.13
gem path rails '< 4'
=> /home/cbliard/.rvm/gems/ruby-2.1.5/gems/rails-3.2.21

Really handy as you can use it to grep or edit files:

grep -R 'Internal server error' "$(gem path thin)"
subl "$(gem path thin)"

Gem environment

  gem env
  gem environment
  
  

Troubleshooting

During analysis I learned that rubygems is overriding ruby's standard require command with its own implementation in order to be able to fully resolve gems during the require call. Me as well as maintainers of bundler are not sure how rubygems actually is able to resolve the “far placed” exts folder.

Fedora's rubygems package separates compiled extensions from the Ruby source-code. You will need to install Fedora's rubygem-bundler package which supports these separate paths.

Install vagrant from source

You can install from source to get the bleeding edge of Vagrant.

Clone the git repository out into any directory.

$ git clone https://github.com/mitchellh/vagrant.git

If you don't have it installed yet, you'll need bundler ( http://bundler.io/ ):

$ sudo gem install bundler

Then, install the gem.

$ bundle install
$ sudo rake install

The dev version will now become the active Vagrant version.

If you want to switch back to the previously active version, simply uninstall the dev version.

$ gem uninstall vagrant

Choose to remove the “.dev” version.

Troubleshooting

sudo rake install fails because 'bundle install' installs gems locally in ~/.gem.

So only package vagrant in 'pkg'. This fails but vagrant.gem is created in pkg!

  sudo rake install
  

Install vagrant.gem locally (not download from rubygems.org):

  sudo gem install pkg/vagrant.gem
  

This will pull other gems to global gems-folder.

Other source:

Vagrant on RVM

Vagrant on RVM

## References ##
# https://gorails.com/setup/ubuntu/14.10
# https://rvm.io/rvm/install
# https://rvm.io/integration/bundler#cd-hook
# https://github.com/mitchellh/vagrant/wiki/Installing-Vagrant-from-source
# http://gillesfabio.com/blog/2011/03/01/rvm-for-pythonistas-virtualenv-for-rubyists/
 
#Import public key for server
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
#Install RVM
curl -L https://get.rvm.io | bash -s stable
#Load rvm
source ~/.rvm/scripts/rvm
#Set on shell init
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
#Install ruby
rvm list known
rvm install ruby-head
rvm use ruby-2.2.0 --default
#Tell to Rubygems not to install the documentation for each package locally
echo "gem: --no-ri --no-rdoc" > ~/.gemrc
git clone https://github.com/mitchellh/vagrant.git
cd vagrant
#Install version needed for vagrant
gem install bundler -v '1.7.13'
chmod +x .rvm/hooks/after_cd_bundler

# this goes to ./bin/ --> bundle _1.7.13_ install --binstubs=./bundler_stubs
# this package vagrant-xx.gem? --> bundle _1.7.13_ exec rake install
#vagrant 1.7.2 built to Vagrant on RVM

# install on system
sudo gem install pkg/vagrant-1.7.2.gem

# Running
rvm use system
vagrant box list

IMPORTANT! Nokogiri builds and uses a packaged version of libxslt.

If this is a concern for you and you want to use the system library instead, abort this installation process and reinstall nokogiri as follows:

gem install nokogiri -- --use-system-libraries

If you are using Bundler, tell it to use the option:

bundle config build.nokogiri --use-system-libraries
bundle install

Notes

ruby sandbox

I'll mention the way I do this with Bundler (which I use with RVM - RVM to manage the rubies and a default set of global gems, Bundler to handle project specific gems)

bundle install --binstubs --path vendor

Running this command in the root of a project will install the gems listed from your Gemfile, put the libs in ./vendor, and any executables in ./bin and all requires (if you use bundle console or the Bundler requires) will reference these exes and libs.

Works for me.

puppet modules mapping