rubyvagrantpuppetvagrant-provision

Specify custom location for Rubygems to install via package type


I've installed Ruby in a custom location (on an Ubuntu box, into /opt/rubies using ruby-install) and when it comes to declarations like this:

  package { 'bundler':
    ensure   => 'installed',
    provider => 'gem',
    require =>  Exec["Install Ruby"],
  }

They fail (or install for the wrong version of Ruby) because it's looking for the Rubygems' gem command in the wrong place (/usr/bin). I can think of a few ways I might fix this:

  1. Tell package which version of gem I want used, but I don't see anything in the docs for that.
  2. Add the correct bin directory to the PATH, but I don't know which user is running the provisioner and hence, where to change the PATH. Or should I change the path along with the Ruby installation?
  3. Using an exec declaration instead.

Obviously, using package is very convenient so any way to keep using that would be my preference.


Solution

  • If you want to keep using package, you have two options: