Could not find puppet (>= 0) amongst [] (Gem::LoadError)

Problem

When you try to apply the puppet configuration into a vagrant box and using systemwide rvm installation (if you follow the instructions here), you have the following error:

vagrant@precise64:~$ sudo puppet apply --verbose puppet/manifests/site.pp
/usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find puppet (>= 0) amongst [] (Gem::LoadError)
from /usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems.rb:1231:in `gem'
from /usr/local/rvm/gems/ruby-1.9.3-p327/bin/puppet:18:in `
' from /usr/local/rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `eval' from /usr/local/rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `
'

Solution

Use rvmsudo instead of sudo to make sure that the paths are correct:

vagrant@precise64:~$ rvmsudo puppet apply --verbose puppet/manifests/site.pp

Vagrant – rvm – ruby – puppet installation instructions

Problem

In order to install a vagrant box with rvm and puppet following the examples in the ‘Deploying Rails’ book, the updated steps needed are described below.
The two main differences are a) rvm system wide installation as recommended here, and b) the puppet 3.0.1 version support of ruby 1.9.3 here

Solution

So below are the steps followed to make it work.

  1. Remove system ruby
    sudo rm -rf /opt/vagrant_ruby/
  2. Remove vagrant_ruby.sh script as it adds a path that no longer exists:
    sudo rm /etc/profile.d/vagrant_ruby.sh
  3. Install rvm with system wide installation:
    curl -L get.rvm.io | sudo bash -s stable
  4. Add vagrant user and any other additional user to the rvm group:
    sudo usermod --append --groups rvm vagrant (or ubuntu)
  5. Exit and login back in to install ruby 1.9.3-p327 (current)
    vm$ exit
    $ vagrant ssh
    vm$ rvm install 1.9.3-p327
  6. install necessary ruby dependencies suggestest by previous command:
    sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
  7. Creat a gemset to be used with the desired rvm ruby version:
    rvm gemset create rails3_2_11
  8. Use the created gemset to install puppet gem:
    rvm gemset use rails3_2_11
  9. Install puppet as the vagrant user and NOT as sudo:
    gem install puppet -v 3.0.1
  10. install the puppet user and group as per book instructions:
    vm$ sudo useradd --comment "Puppet" --no-create-home --system --shell /bin/false puppet
  11. Optionally create a puppet directory to put manifests and modules and create a .rvmrc file to use specified gemset, by adding the following line to puppet/.rvmrc:
    rvm gemset use rails3_2_11
  12. use rvmsudo instead of sudo to apply the puppet scripts:
    rvmsudo puppet apply --verbose puppet/manifests/site.pp

Could not find activesupport-3.0.12 in any of the sources (Bundler::GemNotFound)

Problem

You are trying to update your rails app deployed on a server, for example from 3.0.11 to 3.0.12, and at the same time trying to update the Ruby version from 1.9.2 to 1.9.3 but you are getting the following error from passenger:

    Could not find activesupport-3.0.12 in any of the sources (Bundler::GemNotFound)

Solution

You would need to reinstall and compile the passenger module with the newest Ruby 1.9.3 installation.

gem install passenger

passenger-install-apache2-module

and then modify the apache configuration file as in:

The Apache 2 module was successfully installed.                   

Please edit your Apache configuration file, and add these lines:

   LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
   PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11
   PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p125/ruby

After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!

and then reload your apache configuration

sudo /etc/init.di/apache2 reload

Creating a Vagrant Box with Debian Lenny 32, rvm and Ruby 1.9.3

As an addition to the excellent beta book ‘Deploying Rails’, as I had problems using the suggested lucid64 image, I’ve tried to install a debian lenny 32 image with rvm and Ruby 1.9.3.

The steps needed are listed below

 

  1. Download the lenny package:
    localhost$ vagrant box add debian-lenny-32 https://s3-eu-west-1.amazonaws.com/glassesdirect-boxen/debian/debian_lenny_32.box
  2. Make a new directory for the virtual box:
    localhost$ mkdir -p ~/deployingrails/lenny32
  3. change into created directory and create the Vagrant file:
    localhost$ cd ~/deployingrails/lenny32
    vagrant init
  4. change the Vagrant file to use the virtual box we have downloaded:
    Vagrant::Config.run do |config|
      config.vm.box = "lenny32"
    end
  5. Start the VM:
    localhost$ vagrant up
  6. If there is a warning about the Guest additions here install the latest guest additions by following the description here, but only use the update and upgrade steps as:
    localhost$ vagrant ssh
    vagrant$ sudo apt-get update
    vagrant$ sudo apt-get upgrade
  7. After finishing the upgrade logout (exit) from the VM and issue the command to restart the VM:
    localhost$ vagrant reload
  8. login to the VM again:
    localhost$ vagrant ssh
  9. Install curl to be able to download the installation script for:
    vagrant$ sudo apt-get install curl
  10. Download and install rvm by using the script described here http://beginrescueend.com/rvm/install/ :
    vagrant$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
  11. Add the loading of the RVM function into .bashrc, by running the following in the command prompt:
    vagrant$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bashrc
  12. Reload the bashrc file:
    vagrant$ source ~/.bashrc
  13. Make sure that the rvm is loaded as function:
    vagrant$ type rvm | head -1
    rvm is a function
  14. Run the rvm requirement to see the needed libraries and then run the suggested ones (except libreadline6 and libreadline6-dev that are not there in debian):
    vagrant$ sudo apt-get install build-essential openssl curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison
  15. Install Ruby 1.9.3 :
    vagrant$ rvm install ruby-1.9.3
  16. Use the ruby 1.9.3 as default:
    vagrant$ rvm use 1.9.3 --default
  17. Finally create a new VM package to use in future:
    localhost$ vagrant package --output lenny32-rvm-ruby193
  18. And add it our box list:

    localhost$ vagrant box add lenny32-rvm-ruby193 lenny32-rvm-ruby193
    localhost$ vagrant box list

cannot load such file — zlib

Problemo

You are trying to install a gem with rvm but you are getting the following error:

ERROR: Loading command: install (LoadError
cannot load such file — zlib
ERROR: While executing gem … (NameError)
uninitialized constant Gem::Commands::InstallCommand

Solution

Following from the post here

you would need to install the zlib library with rvm, uninstall your ruby version and then install the ruby version again with the folowing:

 

rvm pkg install zlib

rvm uninstall 1.9.3

rvm install 1.9.3

Using named gemsets with rvm

Problem

You want to be able to use different gems/rails version for your application after installing the latest rails version, without having to use bundle exec.

 

Solution

You can use the named gemsets with rvm.

More instructions are here: http://beginrescueend.com/gemsets/basics/

so you can install two gemsets for example ruby-1.9.3-p0@rails3_0_11 and another with ruby-1.9.3-p0@rails3_2_1

you could then do :

rvm gemset create rails3_0_11 rails3_2_1

rvm 1.9.3-p0@rails3_0_11
gem install rails -v 3.0.11

rvm 1.9.3-p0@rails3_2_1
gem install rails -v 3.2.1

rvm gemset use rails3_0_11
bundle install

you could then also use some aliases in your ~/.bashrc file to be able to use the gemsets by using only one command as for example in ($ rvm3011):

# Rails 3.0.x
alias rvm3011="rvm gemset use rails3_0_11"
alias rvm3012="rvm gemset use rails3_0_12"

# Rails 3.2.x
alias rvm321="rvm gemset use rails3_2_1"
alias rvm322="rvm gemset use rails3_2_2"