How do I fix broken gems in Leopard?

/usr/bin/gem:23: uninitialized constant Gem::GemRunner (NameError)

This is what I get when I try to run anything like "sudo gem update rails"

I tried to upgrade my 1.2.6 rails install running on Leopard. I think the problem started because I forgot to run my "gem install rails" command (to upgrade to 2.0) using "sudo". That and I forgot to use "update" instead of "install" - so things are a bit crazy now.

I can run rails and the version in the Terminal is 2.0.1 - but when I am getting a MySQL related error when I try to view the application's framework. I thought I might need to update my gems, so I downloaded the latest package and ran "ruby setup.rb". I also made sure that the mysql gem was up to date. Now nothing related to gems is working.

I'm new to rails and I'm used to the whole "it just works" mentality of developing on a Mac. So I really don't know where to begin when I'm troubleshooting rails.

How do I make sure that my gems are properly installed and reinstall them if I need to? And on that note, does anyone know where all the gems are kept in Leopard? I found references to them in /Library/Ruby/ 1.8/Gems and /System/Library/Frameworks/ruby.framework

Once I do that, is it possible to roll back to rails 1.2.6 so I can get a stable environment again before trying to upgrade to 2.0 again?

Thanks for any help you might be able to give.

I think you went wrong by installing gems the way you did.

Go to macosforge under the Ruby section and find the FAQ.

:slight_smile: Very funny. I love my Mac. It'll take a lot more than a broken set of gems to make me give it up.

Thanks, I'll look into that.

Eureka! All I had to do was take the latest gems and run "sudo ruby setup.rb" again. it copied over all the other gems (that I guess had the wrong permissions) and now I can run "gem" scripts again. I'm still having issues with the upgrade to 2.0 though, any ideas about how I might be able to downgrade to 1.2.6, then try again?

I'm not at my system right now but I think you'll need to update gem
to the current (0.9.?) version before going to rails 2.0.1

sudo gem update -system

Then just

sudo gem install rails

I think the gem update command is correct, but if it errors, check the
rails site for the correct command.

Cheers!

Jim

Thanks, Jim. (BTW, it's "sudo gem update --system" with two hyphens. But I got the idea, I just ran help to find the correct syntax.

I was pretty sure that I already had 0.9, but I went ahead and updated it then installed rails again. Still the same problem. After creating a new rails project, I bring up localhost:3000 and check the info about the application's environment and I get this:

Mysql::Error in Rails/infoController#properties

followed by this:

/Library/Ruby/Gems/1.8/gems/activerecord-2.0.1/lib/active_record/ connection_adapters/mysql_adapter.rb:471:in `real_connect' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.1/lib/active_record/ connection_adapters/mysql_adapter.rb:471:in `connect' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.1/lib/active_record/ connection_adapters/mysql_adapter.rb:165:in `initialize' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.1/lib/active_record/ connection_adapters/mysql_adapter.rb:88:in `new' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.1/lib/active_record/ connection_adapters/mysql_adapter.rb:88:in `mysql_connection' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.1/lib/active_record/ connection_adapters/abstract/connection_specification.rb:291:in `send' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.1/lib/active_record/ connection_adapters/abstract/connection_specification.rb:291:in `connection=' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.1/lib/active_record/ connection_adapters/abstract/connection_specification.rb:259:in `retrieve_connection' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.1/lib/active_record/ connection_adapters/abstract/connection_specification.rb:78:in `connection' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.1/lib/active_record/ query_cache.rb:8:in `cache' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.1/lib/action_controller/ caching.rb:677:in `perform_action' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.1/lib/action_controller/ base.rb:524:in `send' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.1/lib/action_controller/ base.rb:524:in `process_without_filters' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.1/lib/action_controller/ filters.rb:685:in `process_without_session_management_support' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.1/lib/action_controller/ session_management.rb:123:in `process' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.1/lib/action_controller/ base.rb:388:in `process' /Library/Ruby/Gems/1.8/gems/activesupport-2.0.1/lib/active_support/ dependencies.rb:489:in `load' /Library/Ruby/Gems/1.8/gems/activesupport-2.0.1/lib/active_support/ dependencies.rb:489:in `load' /Library/Ruby/Gems/1.8/gems/activesupport-2.0.1/lib/active_support/ dependencies.rb:342:in `new_constants_in' /Library/Ruby/Gems/1.8/gems/activesupport-2.0.1/lib/active_support/ dependencies.rb:489:in `load' /Library/Ruby/Gems/1.8/gems/rails-2.0.1/lib/commands/servers/ mongrel.rb:64 /Library/Ruby/Gems/1.8/gems/activesupport-2.0.1/lib/active_support/ dependencies.rb:496:in `require' /Library/Ruby/Gems/1.8/gems/activesupport-2.0.1/lib/active_support/ dependencies.rb:342:in `new_constants_in' /Library/Ruby/Gems/1.8/gems/activesupport-2.0.1/lib/active_support/ dependencies.rb:496:in `require' /Library/Ruby/Gems/1.8/gems/rails-2.0.1/lib/commands/server.rb:39

Any thoughts?

Thanks!

Well I think I did the exact same thing... And then it dawned on me
that in creating that new rails app that I didn't go into mysql and
create any databases for it, so checking the app properties ran into a
problem:-) slapped my head, created a -development database and the
all was fine.

Cheers!

Jim

Why don' you just leave the Leopard files alone, and use Macports.

I never touch anything in /usr/ (/usr/lib) actually...

Just use macports. Everything goes to /opt/local/

you have to add this to your ~/.bashrc or ~/.bash_profile

export PATH=/opt/local/bin:/$PATH

I NEVER had a single issue since the 1st day I have my MACBOOK. Which is about 1 year from now, and I work with ruby/rubygems everyday.

I wrote an entry on my blog about this, fairly simple fix:

open a terminal sudo emacs /usr/bin/gem

then add the line require 'rubygems/gem_runner' as so:

deps = %w(actionpack activerecord actionmailer activesupport actionwebservice) require 'rubygems' require 'rubygems/gem_runner' Gem.manage_gems