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:
- Tell
package
which version ofgem
I want used, but I don't see anything in the docs for that. - 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?
- 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.
If you want to keep using
package
, you have two options:PATH
that the puppet agent runs on.gem
path. Like this, except you don't need to replace theuninstall
method, so you can lose that part. Then you'll changeprovider => gem
toprovider => whatever_provider_name_you_chose
.