views:

514

answers:

3

I have what looks like multiple versions of rubygems installed on my machine, when i gem list i see all my gems, but when i go to run scripts, i get error messages like

Missing these required gems:
  SystemTimer

Is there any methodology I can follow to remove all versions of rubygems but one? Ideally i would like to be able to access all the gems that show up under gem list in my programs.

From Gem Environment - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

Still if i run:

$ /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby script/mailer_daemon_fetcher start production
no such file to load -- SystemTimer
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/rails/gem_dependency.rb:208:in `load'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:307:in `load_gems'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:307:in `each'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:307:in `load_gems'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:164:in `process'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `send'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `run'
./script/../config/environment.rb:13
script/mailer_daemon_fetcher:5:in `require'
script/mailer_daemon_fetcher:5
no such file to load -- SystemTimer
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/rails/gem_dependency.rb:208:in `load'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:307:in `load_gems'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:307:in `each'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:307:in `load_gems'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:169:in `process'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `send'
/Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `run'
./script/../config/environment.rb:13
script/mailer_daemon_fetcher:5:in `require'
script/mailer_daemon_fetcher:5
Missing these required gems:
  SystemTimer  

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

note in the above i'm manually calling ruby**/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby** this is the same file that my /usr/bin/ruby is symlinked to, and also my GEM_PATH is set to be /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8

full output of gem environment is available here: http://pastie.org/661104

+1  A: 
gem cleanup

it will delete all old gem versions

you have problems with environment - running gem gets others than when you use rubygems in script

look at output of (especially GEM PATHS)

gem environment

also you can compare results of ruby -e 'p ENV' executed in shell and p ENV execute somewhere in your code — look for differences in gem related stuff

tig
gem cleanup choked on a few installs and said they were dependencies, can i just remove the folders manually? I posted my GEM PATHS at the top after i ran gem cleanup. I'm still not able to utilize system timer inside of scripts
ThinkBohemian
you can delete folder with extracted gem, but note that there are also cached versions of gem, its specification, folder with documentation, also some gems install binaries
tig
+1  A: 

I have a feeling that you might be using a different version of ruby than ruby gems is. Either that or ruby doesn't know where to look for your gems.

See the the gem installation guide to ensure your environment is configured to use gems.

If you're still having problems after following instructions, ensure that you haven't got multiple versions of ruby installed. In the event that there are multiple version of Ruby available, make sure your scripts are calling the same version of Ruby as gem is. This is done by comparing the gem environment listing for RUBY_EXECUTABLE against your scripts' shebang line. Double check to follow any symlinks, because most distribution based installations of ruby will symlink /usr/bin/ruby to /usr/bin/ruby1.8

You should also check that your gems were installed by the same user who is running the script.

If you ran gem install without root privileges the new gems will be installed in your home directory. If you're running a script that depends on these gems as another user. Those installed gems will not be found. However, there's no problems if your gems are installed by root and a different user is running scripts that requires those gems.

I experienced this problem while switching from Ruby to Ruby Enterprise Edition. I found that I had to install all my required gems again using REE's instance of gem.

EmFi
how would one go about ensuring that their scripts are calling the same version of ruby as my gems ?
ThinkBohemian
Updated answer with new possible solution.
EmFi
updated with more information, looks like all versions line up
ThinkBohemian
Did you check the user situation. If you ran gem install as snomaninthesun the gems won't be found for a cron job running under root. Also does what is stored in the Gem.path variable when called from your scripts?
EmFi
+1  A: 

I think the problem is SystemTimer loads slightly oddly so you need more configuration in environment.rb

The "problem" seems to be that gem is called "SystemTimer" but you need to load "system_timer". In order to accomplish this with environment.rb you should use:

  config.gem 'SystemTimer', :lib => 'system_timer'

That seemed to solve the same problem for me.

byronsalty