Problem when two versions of the activesupport gem are installed
If two versions are installed, Whenever loads the newer one, and then if you try to use Whenever with a Rails app that requires the older version of the gem, it dies:
/usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:149:in activate': can't activate activesupport (= 2.1.1, runtime), already activated activesupport-2.3.2 (Gem::Exception)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:165:in activate' from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:164:ineach'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:164:in activate' from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:49:ingem'
from ./config/boot.rb:59:in load_rails_gem' from ./config/boot.rb:53:inload_initializer'
from ./config/boot.rb:38:in run' from ./config/boot.rb:11:inboot!'
... 7 levels...
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
require'
from /usr/local/lib/ruby/gems/1.8/gems/javan-whenever-0.1.7/bin/whenever:7 from /usr/local/bin/whenever:19:in `load' from /usr/local/bin/whenever:19
I am experiencing this bug as well with 2.2.2 and 2.3.2 installed on my production system. Here is my stack trace:
/usr/local/lib/site_ruby/1.8/rubygems.rb:149:in activate': can't activate activesupport (= 2.2.2, runtime), already activated activesupport-2.3.2 (Gem::Exception) from /usr/local/lib/site_ruby/1.8/rubygems.rb:165:inactivate'
from /usr/local/lib/site_ruby/1.8/rubygems.rb:164:in each' from /usr/local/lib/site_ruby/1.8/rubygems.rb:164:inactivate'
from /usr/local/lib/site_ruby/1.8/rubygems.rb:49:in gem' from ./config/boot.rb:59:inload_rails_gem'
from ./config/boot.rb:53:in load_initializer' from ./config/boot.rb:38:inrun'
from ./config/boot.rb:11:in boot!' from ./config/boot.rb:109 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in require' from ./Rakefile:4 from /usr/lib/ruby/gems/1.8/gems/javan-whenever-0.3.0/lib/whenever.rb:6:inload'
from /usr/lib/ruby/gems/1.8/gems/javan-whenever-0.3.0/lib/whenever.rb:6
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from /usr/lib/ruby/gems/1.8/gems/javan-whenever-0.3.0/bin/whenever:7
from /usr/bin/whenever:19:in `load'
from /usr/bin/whenever:19
Thanks. The quick and dirty fix is to uninstall the version of activesupport you're not using. I'l get a fix in place soon.
I have the same problem. Looking forward to the fix as whenever looks awesome :-)
+1 have this same issue. Going to try removing activesupport 2.3.2 since I'm not using it at the moment.
I am not using Rails 2.3 on my slice yet but I had some of the gems installed. I removed gems returned by gem list | grep 2.3.2, re-deployed and verified the correct generated crontab file. Thanks.
Just to ditto on the 2.2.2 vs 2.3.2 problem. I need both installed on my mac (personal projects are using 2.3.2, but work project using 2.2.2), so the workaround isn't an option. ::(
+1 on this.
Removed activesupport dependency from gemspec. Closed by 6fbb125296a04187b8c079dab521ba63158e9ded
Version 0.3.1 was just released and should fix this issue. Let me know if it doesn't.
Didn't work:
I got the message:
./Rakefile:3: undefined method import' for main:Object (NoMethodError) from /usr/lib/ruby/gems/1.8/gems/javan-whenever-0.3.7/lib/whenever.rb:6:inload'
from /usr/lib/ruby/gems/1.8/gems/javan-whenever-0.3.7/lib/whenever.rb:6
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from /usr/lib/ruby/gems/1.8/gems/javan-whenever-0.3.7/bin/whenever:7
from /usr/bin/whenever:19:in `load'
from /usr/bin/whenever:19
while my gem list is: actionmailer (2.3.4) actionpack (2.3.4) activemerchant (1.4.2, 1.4.1) activerecord (2.3.4) activerecord-tableless (0.1.0) activeresource (2.3.4) activesupport (2.3.4) authlogic (2.1.3) builder (2.1.2) calendar_date_select (1.15) capistrano (2.5.10) chronic (0.2.3) compass (0.8.17) fastercsv (1.5.0) fastthread (1.0.7) git (1.2.5) haml (2.2.15) haml-edge (2.3.100) highline (1.5.1) hoe (2.3.3) htmlentities (4.2.0) javan-whenever (0.3.7) json_pure (1.2.0) mislav-will_paginate (2.3.11) mysql (2.8.1) net-scp (1.0.2) net-sftp (2.0.4) net-ssh (2.0.16) net-ssh-gateway (1.0.1) passenger (2.2.7) rack (1.0.1) rails (2.3.4) rake (0.8.7) RedCloth (4.2.2) rmagick (2.12.2) rsl-stringex (1.0.3) rspec (1.2.9) rspec-rails (1.2.9) rubyforge (2.0.3) rubyzip (0.9.1) searchlogic (2.3.9) spree (0.9.2) tlsmail (0.0.1)
You're using an old version of the gem, please upgrade to the newest version (0.4.1 at the moment). Note that it is now hosted at gemcutter.org.
Thank you for the quick response. Unfortunately I still get the same error message:
./Rakefile:3: undefined method import' for main:Object (NoMethodError) from /usr/lib/ruby/gems/1.8/gems/whenever-0.4.1/lib/whenever.rb:5:inload'
from /usr/lib/ruby/gems/1.8/gems/whenever-0.4.1/lib/whenever.rb:5
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from /usr/lib/ruby/gems/1.8/gems/whenever-0.4.1/bin/whenever:7
from /usr/bin/whenever:19:in `load'
from /usr/bin/whenever:19
It's choking when Whenever loads the Rakefile from your Rails (I assume) app. What's on line 3 of your Rakefile?
THe rakefile looks like this: require 'rubygems' require 'rake'
require 'lib/whenever/version.rb'
begin require 'jeweler' Jeweler::Tasks.new do |gemspec| gemspec.name = "whenever" gemspec.version = Whenever::VERSION gemspec.summary = "Clean ruby syntax for defining and deploying messy cron jobs." gemspec.description = "Clean ruby syntax for defining and deploying messy cron jobs." gemspec.email = "[email protected]" gemspec.homepage = "http://github.com/javan/whenever" gemspec.authors = ["Javan Makhmali"] gemspec.add_dependency("chronic", '>= 0.2.3') end Jeweler::GemcutterTasks.new rescue LoadError puts "Jeweler not available. Install it with: sudo gem install jeweler -s http://gemcutter.org" end
require 'rake/testtask' Rake::TestTask.new(:test) do |test| test.libs << 'lib' << 'test' test.pattern = 'test/*.rb' test.verbose = true end
task :test => :check_dependencies
task :default => :test
So, line 3 is empty
That's Whenever's Rakefile.. Whenever tries to load the Rakefile from YOUR app, and it's dying on line 3 of it: "./Rakefile:3: undefined method `import' for main:Object (NoMethodError)"
Ah, my application's Rakefile does that in line 3:
import File.join(SPREE_ROOT, 'Rakefile')
And my application starts successfully
maybe change that "import" to "load"? i've never seen import in ruby.
That helps! In Spree (www.spreecommerce.com) that Rakefile uses "import". I change it to "load"
Thank you very much, javan!
Alexander
this issue is still arising for me. my situation is similar to a poster above. the project has rails 2.3.2 vendored, but there is rails 2.3.5 installed on my machine. when it tries to load active_support from the whenever.rb file, i get the NoMethodError.
my workaround is to wrap the call so that it checks if rails is present in vendor first and uses that version if its available. otherwise, it will go through the routine of requiring active support.
just experienced the first listing of this as well...
/opt/ruby-enterprise-1.8.6-20090421/lib/ruby/site_ruby/1.8/rubygems.rb:258:in `activate': can't activate activesupport (= 2.3.5, runtime) for [], already activated activesupport-2.1.2 for ["rails-2.1.2"] (Gem::Exception)
from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:35:in `require'
from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:510:in `require'
from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:355:in `new_constants_in'
from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:510:in `require'
from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/whenever-0.4.2/lib/whenever.rb:15
from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/whenever-0.4.2/bin/whenever:5
from /opt/ruby-enterprise-1.8.6-20090421/bin/whenever:19:in `load'
from /opt/ruby-enterprise-1.8.6-20090421/bin/whenever:19
I'm on whenever 0.4.2. my quick fix was simply to rescue Gem::Exception with it doing nothing. The pertinent part of lib/whenever.rb is ...
begin
require 'active_support/all'
rescue LoadError
warn 'To use Whenever you need the active_support gem:'
warn '$ gem install activesupport'
exit(1)
rescue Gem::Exception
# nothing
end
ymmv