views:

57

answers:

2

Lots of confusion and difficulty related to gem installation. My gem environment:

RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin10]
  - INSTALLATION DIRECTORY: /opt/local/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /opt/local/bin/ruby
  - EXECUTABLE DIRECTORY: /opt/local/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-darwin-10
  - GEM PATHS:
     - /opt/local/lib/ruby/gems/1.8
     - /Users/apple/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - :sources => ["http://gems.rubyforge.org/"]
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/

The problem is one where I will add (eg) to environment.rb :

  config.gem 'authlogic'

All good, now when I run

gem install authlogic
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions into the /opt/local/lib/ruby/gems/1.8 directory.

running it with sudo is fine :

Dans-iMac-335:authlogic apple$ sudo rake gems:install
Password:
(in /Users/apple/Documents/projects/authlogic)
gem install authlogic
Successfully installed authlogic-2.1.6
1 gem installed
Installing ri documentation for authlogic-2.1.6...
Installing RDoc documentation for authlogic-2.1.6...

but running rake tasks throws an error :

Dans-iMac-335:authlogic apple$ rake db:migrate
(in /Users/apple/Documents/projects/authlogic)
Missing these required gems:
  authlogic  

You're running:
  ruby 1.8.7.174 at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
  rubygems 1.3.5 at /Users/apple/.gem/ruby/1.8, /Library/Ruby/Gems/1.8, /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8

Run `rake gems:install` to install the missing gems.

I can't see what the problem is. And I'm going out of my mind. The directory at the 'other' gems location :

Dans-iMac-335:authlogic apple$ ls /Users/apple/.gem/ruby/1.8/gems
actionmailer-2.2.2  activeresource-2.2.2    aws-s3-0.6.2        mysql-2.8.1     rails-2.2.2     xml-simple-1.0.12
actionpack-2.2.2    activeresource-2.3.3    builder-2.1.2       packet-0.1.15       rake-0.8.7
actionwebservice-1.2.3  activesupport-2.2.2 chronic-0.2.3       pg-0.8.0        rest-client-1.3.1
activerecord-2.2.2  activesupport-2.3.3 mime-types-1.16     rack-1.0.0      sqlite3-ruby-1.0.1
activerecord-2.3.5  activesupport-2.3.5 mongrel-1.1.5       rack-1.0.1      taps-0.2.26

This, I assume, is the default OSX rails system? The first location gives the much fuller set that represents my normal environment. Since my projects depend on many of these, and they aren't present in the other directory, this is verifiably the location that gems are being pulled from in my development environment:

Dans-iMac-335:authlogic apple$ ls /opt/local/lib/ruby/gems/1.8/gems
RedCloth-4.2.3          crack-0.1.8         mime-types-1.16         rack-1.1.0          sinatra-0.9.2
actionmailer-2.3.5      daemons-1.0.10          minitest-1.4.2          radiant-0.8.1           sinatra-1.0
actionmailer-2.3.8      faker-0.3.1         mogli-0.0.14            rails-2.2.2         spree-0.10.2
actionpack-2.3.5        fastthread-1.0.7        mongrel-1.1.5           rails-2.3.5         sqlite3-ruby-1.0.1
actionpack-2.3.8        gem_plugin-0.2.3        mutter-0.5.3            rails-2.3.8         sqlite3-ruby-1.2.5
activemerchant-1.5.1        google-geocode-1.2.1        mysql-2.8.1         rc-rest-3.0.0           state_machine-0.8.0
activerecord-2.3.8      hashie-0.4.0            net-scp-1.0.2           rest-client-1.0.3       stringex-1.0.3
activerecord-tableless-0.1.0    heroku-1.10.8           net-sftp-2.0.2          rest-client-1.6.1       taps-0.2.19
activeresource-2.3.5        highline-1.5.1          net-ssh-2.0.15          rmagick-2.13.1          taps-0.3.13
activeresource-2.3.8        hoe-2.3.3           net-ssh-gateway-1.0.1       ruby-hmac-0.4.0         thor-0.9.9
activesupport-2.3.8     hpricot-0.8.1           nokogiri-1.3.3          ruby-openid-2.1.7       treetop-1.4.8
authlogic-2.1.6         httparty-0.6.1          paperclip-2.3.1.1       rubyforge-2.0.2         whenever-0.3.7
authlogic-oid-1.0.4     json-1.1.9          passenger-2.2.5         rubyforge-2.0.4         will_paginate-2.3.11
aws-s3-0.6.2            json_pure-1.1.9         pg-0.8.0            rubygems-update-1.3.5       xml-simple-1.0.12
builder-2.1.2           json_pure-1.2.4         pg-0.9.0            rubygems-update-1.3.7
capistrano-2.5.9        launchy-0.3.3           polyglot-0.3.1          searchlogic-2.3.5
cgi_multipart_eof_fix-2.5.0 less-1.2.20         postgres-0.7.9.2008.01.28   sequel-3.0.0
configuration-1.1.0     libxml-ruby-1.1.3       rack-1.0.1          sequel-3.15.0

So, if the system uses this /opt/local/lib/ruby/gems/1.8/gems directory, why can't it see it when I call rake? And what can I do about it?

A: 

I don't see what the problem is, but have you tried running "gem list " to see what gems your system recognizes as having installed?

Anna
I did, and the "missing" gems are in it. But see my answer below: the problem appears to be that when rake runs and loads the environment, it does not use the $PATH variable that rails does use when it installs gems.
Dan Donaldson
A: 

My solution was to change the #! line of rake.rb to point to the location of the ruby installation that has the gems.

From what I learned, when you're installing gems, rails takes account of the $PATH variable, but when loading the environment when rake is called, it doesn't. So rake doesn't know about those locations. The answer, then, was to direct rake's attention to the right location.

Dan Donaldson