How do I run a Ruby Gem? How do I run a Ruby Gem? ruby ruby

How do I run a Ruby Gem?


It seems that Debian/Ubuntu drops ruby gems into /var/lib/gems/1.8/bin.

So the solution (at least for Ubuntu/Debian) is:

$ sudo -s# echo 'PATH=/var/lib/gems/1.8/bin:$PATH' > /etc/profile.d/gemspath.sh# chmod 0755 /etc/profile.d/gemspath.sh

...and then open a new shell session.

(This is fixed in Ubuntu 11.10.)


If you happen to have installed Ruby through rbenv, you'll need to execute the following command

rbenv rehash


On macOS I had to add the gem executable directory to the path.
Add these lines to your ~/.bashrc file, and reopen the terminal to refresh the env vars.

# gem                                                                      gembin=`(gem env | sed -n "s/.*EXECUTABLE DIRECTORY: \(.*\)/\1/p")`export PATH=$gembin:$PATH