Ruby/gem installation paths scattered all over, cause?

1

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.

Blub

Posted 2011-04-11T09:21:14.330

Reputation: 448

I am facing the exact same issue :) – Genadinik – 2011-04-21T17:06:42.580

Answers

1

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.

Blub

Posted 2011-04-11T09:21:14.330

Reputation: 448

Did you figure out why the directory structure was so strange and why it thought that you had version 1.3.7 installed? – Genadinik – 2011-04-21T17:10:29.053

@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 – 2011-05-20T08:34:08.890

0

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?

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

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)


solution:

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.

JonnyJD

Posted 2011-04-11T09:21:14.330

Reputation: 3 203