Specify custom location for Rubygems to install via package type

93 Views Asked by At

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. Any help or insight will be much appreciated.

1

There are 1 best solutions below

1
On BEST ANSWER

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

  • You can change the PATH that the puppet agent runs on.
  • You can subclass the provider with the desired gem path. Like this, except you don't need to replace the uninstall method, so you can lose that part. Then you'll change provider => gem to provider => whatever_provider_name_you_chose.