can you help me understand my ruby folder structure? I don't understand why my gems are scattered all over and why they aren't recognised commands.

I'll explain how my installation looks like first:


The first is a soft link to ruby1.9.1 because the "ruby" command didn't work in the terminal. I did the same with "gem". I installed rubygems through downloading, extracting and then running setup.rb here: (I created the "ruby" folder)



I installed a few gems with "sudo gem install"

> gem list

 *** LOCAL GEMS ***

 compass (0.10.6)
 haml (3.0.25)
 mustache (0.99.3)
 rake (0.8.7)

So far so good? Well not quite, as it turns out the command "compass version" doesn't seem to exist. My confusion grows with each folder I look into. The following path doesn't make any sense to me, for example. Why would it be hidden? Why is mustache the only gem inside this folder?


First of all, here is "gem environment", which makes even less sense, because I have definately installed rubygems-1.7.2 like I told you in the first paragraph, but here it shows an ancient version 1.3.7. Why? I installed Ubuntu the day before yesterday.

  RubyGems Environment:
  - RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [x86_64-linux]
  - INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
  - RUBY EXECUTABLE: /usr/bin/ruby1.9.1
  - EXECUTABLE DIRECTORY: /var/lib/gems/1.9.1/bin
    - ruby
    - x86_64-linux
     - /var/lib/gems/1.9.1
     - /home/pc/.gem/ruby/1.9.1
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - http://rubygems.org/

ruby --version returns "ruby 1.8.7"........... Also, as it turns out, all gems are installed into this folder (mustache too! even though it already is inside the other folder), just as "ruby environment" claims:


But none of these gems work. I can't call any of these, except rake. So here is where I probably made the mistake, I think I used "apt-get install rake" in addition to "gem install rake", because the command "rake" wasn't recognised, and the command prompt suggested it. I may have done so with rubygems too... I'm new to Linux, and I figured that the command prompt knew how to install this stuff properly.


It can't be normal that I have to create syslinks all over, right? In Windows I didn't run into this problem.

  • I am facing the exact same issue :)
    – Genadinik
    Apr 21, 2011 at 17:06

2 Answers 2


I installed rvm, I still don't know why there was such a mess but now I can just force a certain ruby version easily, and I know where all the gems get installed into. (into the rvm directory) Works for me.

  • Did you figure out why the directory structure was so strange and why it thought that you had version 1.3.7 installed?
    – Genadinik
    Apr 21, 2011 at 17:10
  • @Genadinik: No sorry, I didn't investigate any further. For other reasons I'm actually on Fedora15 now, and here everything worked with no strange problems.
    – Blub
    May 20, 2011 at 8:34

I guess your problem is installing RubyGems manually and not with apt-get. You possibly did the same with ruby or you are missing a meta-package that includes the symlink you created manually.

This is also the same reason why /var/lib/gems/1.9.1/bin, the directory where all the binaries are is not in your $PATH. So you can't find the executables for these gems.

When you upgrade from Ruby 1.8 to Ruby 1.9.3, the gems installed with Ruby 1.8 will still be in the Ruby 1.8 folder. You possibly have RubyGems installed with a different Ruby Version.

The following path doesn't make any sense to me, for example. Why would it be hidden? Why is mustache the only gem inside this folder?


You obviously installed mustache (without sudo) with

gem install mustache

This installs it for the user and the user-install dir is $HOME/.gem/. The folder is hidden so you don't accidently delete it. You might have to add that to your $PATH (or install with --no-user-install)


Don't just download and install RubyGems (and ruby) manually. Use your package manager (aptitude)

Afterwards you can decide if you want to install gems with aptitude or gem install: install-packages-through-apt-get-or-gem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .