Linux – Ruby/gem installation paths scattered all over, cause

linuxrubyrubygemsterminalUbuntu

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:

/usr/bin/ruby
/usr/bin/ruby1.8
/usr/bin/ruby1.9.1

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)

/home/pc/ruby/rubygems-1.7.2/setup.rb

/usr/bin/gem
/usr/bin/gem1.8
/usr/bin/gem1.9.1

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?

/home/pc/.gem/ruby/1.9.1/cache/mustache-0.99.3.gem

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:
  - RUBYGEMS VERSION: 1.3.7
  - 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
      - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /var/lib/gems/1.9.1
     - /home/pc/.gem/ruby/1.9.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - 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:

/var/lib/gems/1.9.1/gems

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.

Best Answer

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.

Related Question