Installed gems aren't installed

Like the subject says, I’ve got a really weird problem.

A co-worker added a couple of gems to our rails project. I installed
these gems on my machine (a macbook, os x 10.5.6), start the server,
and it says it can’t find these gems:

=============
Missing these required gems:
mini_exiftool = 1.0.1
mini_magick = 1.2.3

You’re running:
ruby 1.8.6.114 at /System/Library/Frameworks/Ruby.framework/
Versions/1.8/usr/bin/ruby
rubygems 1.3.1 at /Users/mcv/.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.
Exiting

So I run sudo rake gems:install

which says:

no such file to load – mini_exiftool
(big stack-trace)
/usr/bin/rake:19:in load' /usr/bin/rake:19 no such file to load -- mini_magick /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:ingem_original_require’
(big stack-trace)
/usr/bin/rake:19
no such file to load – mini_exiftool
(stacktrace)
no such file to load – mini_magick
(etc)
gem install mini_exiftool --version “= 1.0.1”
Successfully installed mini_exiftool-1.0.1
1 gem installed
Installing ri documentation for mini_exiftool-1.0.1…
Installing RDoc documentation for mini_exiftool-1.0.1…
gem install mini_magick --version “= 1.2.3”
Successfully installed mini_magick-1.2.3
1 gem installed
Installing ri documentation for mini_magick-1.2.3…
Installing RDoc documentation for mini_magick-1.2.3…

So it seems to claim it successfully installed something, despite being
unable to find it?

rake gems results in the same big stack traces, ending in:

=============

  • [I] RedCloth = 3.0.4
  • [I] rmagick >= 2.3.0
  • [I] mislav-will_paginate >= 2.3.2
  • [R] tzinfo >= 0.3.12
  • [ ] mini_exiftool = 1.0.1
  • [ ] mini_magick = 1.2.3
  • [I] activemerchant
    • [I] activesupport = 2.2.2
    • [I] builder = 2.1.2
      =============

gem list gives a big list of gems, including the two missing ones.

So what’s going wrong here? And how do I fix it?

This might be related to a similar problem I had recently. I couldn’t
get activemerchant to work. It kept failing during require, so I ended
up installing in in the vendor folder of the project. But now it looks
like it’s a fundamental problem with my machine.

I have sucessfully installed gems before, but that was before we
switched from Rails 2.1.0 to 2.2.2. In fact, I had a lot of trouble
getting any version of Rails other than 2.1.0 working. When my
co-worker was using Rails 2.1.1, I was still using 2.1.0, because
when I upgraded, I got an error that it couldn’t start rails 2.1.0
because 2.1.1 was already running. Or something like that.

Anyway, it looks like there’s something seriously wrong the Rails
installation on my machine, but I have no idea what.

This problem is compounded by the fact that I’m both a newbie to
Ruby and to the Mac. So is there anyone with more experience with
this who can tell me what’s wrong?

Thanks,
Martijn.

Martijn,

I have faced some of this. I found that doing
sudo gem update --system
sudo gem cleanup

Really helped. Sometimes I did them a couple times in a row.

The error about Rails 2.1.0 already running (or something like that)
might have to do with the environment.rb file you have, which might
specify a particular rails version. That also used to happen to me,
and I usually had several versions of Rails on one machine. I don’t
believe that’s ideal, so now there’s just one and I edit
environment.rb for each project accordingly.

–Colin

On Jan 29, 2009, at 7:50 PM, Colin S. wrote:

I have faced some of this. I found that doing
sudo gem update --system
sudo gem cleanup

Thanks! I’ll definitely try that.

In the end, I managed to fix it by simply installing everything in
~/.gem

Not the prettiest solution, but at least it seems to work for now.
I guess some gem overview file got corrupted or something then?

The error about Rails 2.1.0 already running (or something like that)
might have to do with the environment.rb file you have, which might
specify a particular rails version.

environment.rb specified Rails 2.2.2 (and 2.1.1 before that), but
despite that at some point ruby tried to load 2.1.0 modules.
Removing 2.1.0 meant it tried to load Rails 1.x, which I think
was installed in a completely different location even.

That also used to happen to me,
and I usually had several versions of Rails on one machine. I don’t
believe that’s ideal, so now there’s just one and I edit
environment.rb for each project accordingly.

I prefer working in the same version of Rails as my co-workers, so
if one project is upgraded and another isn’t, I need both versions
of Rails.

mcv.

On Jan 29, 2009, at 7:50 PM, Colin S. wrote:

I have faced some of this. I found that doing
sudo gem update --system
sudo gem cleanup

This doesn’t seem to do anything for me:

$ sudo gem update --system
Updating RubyGems
Nothing to update
$ sudo gem cleanup
Cleaning up installed gems…
Attempting to uninstall rails-1.2.6
ERROR: While executing gem … (Gem::InstallError)
Unknown gem rails = 1.2.6

So what does this mean? Is my gem installation even more
broken than usual? I do have rails-1.2.6 is another gem
repository:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
gems/1.8/gems

instead of my usual

/Library/Ruby/Gems/1.8/gems

The latter is where all gems are that I installed myself. Both
the ones that worked and later the ones that didn’t.

mcv.

What OS and version and version of ruby?

Sent from my iPhone

On Jan 29, 2009, at 8:51 PM, Julian L. wrote:

What OS and version and version of ruby?

OS X 10.5.6

ruby 1.8.6.114 at /System/Library/Frameworks/Ruby.framework/Versions/
1.8/usr/bin/ruby
rubygems 1.3.1 at /Users/mcv/.gem/ruby/1.8, /Library/Ruby/Gems/1.8, /
System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
gems/1.8

Martijn.

God. You said that, sorry. I’m running on 3 hours sleep. That IS very
strange. Hm.

Sent from my iPhone

Martijn:

I had similar odd symptoms a while back. It turned out that I had two
different versions of both Ruby and RubyGems installed and was trying
to mix and match between them without realizing it.

Older versions of Ruby and Gem want to live in /usr, but newer
versions seem to want to live in /usr/local.

I was confused until I figured out that my development environment
pointed to the newer versions, but my Rails app was pointing to the
older versions. Commands issued from the command line found a new gem
I’d installed, but of course the Rails app couldn’t see it because I
hadn’t installed it for both old and new versions.

If you have two (or more) versions installed on the same machine, make
certain that your environment variables and your configuration files
are set for the correct location for both Ruby and Rubygems. Be sure
to check both Rails environments: development and production. If
your development is done as one user and your Rails app runs as a
different user, be sure to check the settings for both user accounts.

Hope that helps.

Kind Regards,

Greg