Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run a Ruby Gem?

Tags:

This might seem stupid, but I recently tried to install SASS and followed their instructions:

$ gem install sass 
$ sass --watch [...]

So I followed along:

root@server:~# gem install sass
Successfully installed sass-3.1.15
1 gem installed
Installing ri documentation for sass-3.1.15...
Installing RDoc documentation for sass-3.1.15...

root@server:~# sass
bash: sass: command not found

Despite looking around like an idiot trying to find some simple way to run something like gem run sass or some other workaround to make it function, I am more or less at a loss.

like image 1000
Xkeeper Avatar asked Mar 20 '12 18:03

Xkeeper


People also ask

How does Ruby gem work?

The RubyGems software allows you to easily download, install, and use ruby software packages on your system. The software package is called a “gem” which contains a packaged Ruby application or library. Gems can be used to extend or modify functionality in Ruby applications.

Where do RubyGems install to?

When you use the --user-install option, RubyGems will install the gems to a directory inside your home directory, something like ~/. gem/ruby/1.9. 1 . The commands provided by the gems you installed will end up in ~/.

How do I run Gemfile?

run the command bundle install in your shell, once you have your Gemfile created. This command will look your Gemfile and install the relevant Gems on the indicated versions. The Gemfiles are installed because in your Gemfile you are pointing out the source where the gems can be downloaded from.

What is gem in command line?

The gem command allows you to interact with RubyGems. Ruby 1.9 and newer ships with RubyGems built-in but you may need to upgrade for bug fixes or new features. To upgrade RubyGems, visit the download page. If you want to see how to require files from a gem, skip ahead to What is a gem.


1 Answers

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.)

like image 85
Xkeeper Avatar answered Oct 13 '22 11:10

Xkeeper