1

I am trying to use the Whenever gem to schedule a weekly task for sending out an email. I first tested to make the email would actually be sent by making a method call every time a User was updated. So now, I'm trying to have the email sent weekly instead of with every update, however I keep getting the following error in my cron.log file:

Could not find multi_json-1.1.0 in any of the sources (Bundler::GemNotFound)

I've done quite a bit of research and haven't found anything yet, any help would be great. I'll post the relevant code below:

app/mailers/weekly_digest_test_mailer.rb

class WeeklyDigestTestMailer < ActionMailer::Base
  default from: "from@example.com"

  def send_email(user)
    @user = user
    @last_question = @user.questions.last.description

    mail to: @user.email, subject: "This is a test email"
  end
end

app/models/user.rb

def self.send_email_to_user
    WeeklyDigestTestMailer.send_email(self).deliver
end

config/schedule.rb

every 1.minute do
    runner "User.send_email_to_user", :environment => 'development', :output => 'log/cron.log'
end

Gemfile

source 'https://rubygems.org'

gem 'rails', '3.2.0'
gem "bootstrap-tooltip-rails", "~> 0.1"
gem 'whenever', :require => false

group :production do
  gem "exception_notification", "~> 2.5.2", :require => 'exception_notifier'
  gem "mysql", "~> 2.8.1"
end

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end

gem "jquery-rails"
gem "devise", "~> 2.0.4"
gem 'gauge', git: 'git@github.com:AgilionApps/gauges.git'

gem "capistrano"
gem "capistrano-ext"

group :development do
  gem "awesome_print", "~> 1.0.2"
  gem "mail", "2.4.1"
end

group :test do
  gem "minitest", "~> 2.11.2"
  gem "turn", "~> 0.9.3"
  gem "mocha", "~> 0.10.4"
end

group :test, :development do
  gem "sqlite3", "~> 1.3.5"
end

group :staging do
  # gem "pg", "~> 0.13.1"
end  

Bundle install output:

Using rake (0.9.2.2) 
Using i18n (0.6.0) 
Using multi_json (1.1.0) 
Using activesupport (3.2.0) 
Using builder (3.0.0) 
Using activemodel (3.2.0) 
Using erubis (2.7.0) 
Using journey (1.0.3) 
Using rack (1.4.1) 
Using rack-cache (1.1) 
Using rack-test (0.6.1) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.1.2) 
Using actionpack (3.2.0) 
Using mime-types (1.17.2) 
Using polyglot (0.3.3) 
Using treetop (1.4.10) 
Using mail (2.4.1) 
Using actionmailer (3.2.0) 
Using arel (3.0.2) 
Using tzinfo (0.3.31) 
Using activerecord (3.2.0) 
Using activeresource (3.2.0) 
Using ansi (1.4.2) 
Using awesome_print (1.0.2) 
Using bcrypt-ruby (3.0.1) 
Using bundler (1.1.4) 
Using rack-ssl (1.3.2) 
Using json (1.6.5) 
Using rdoc (3.12) 
Using thor (0.14.6) 
Using railties (3.2.0) 
Using rails (3.2.0) 
Using bootstrap-tooltip-rails (0.1) 
Using highline (1.6.11) 
Using net-ssh (2.3.0) 
Using net-scp (1.0.4) 
Using net-sftp (2.0.5) 
Using net-ssh-gateway (1.1.0) 
Using capistrano (2.11.2) 
Using capistrano-ext (1.2.1) 
Using chronic (0.6.7) 
Using coffee-script-source (1.2.0) 
Using execjs (1.3.0) 
Using coffee-script (2.2.0) 
Using coffee-rails (3.2.2) 
Using orm_adapter (0.0.6) 
Using warden (1.1.1) 
Using devise (2.0.4) 
Using exception_notification (2.5.2) 
Using gauge (0.0.2) from git@github.com:AgilionApps/gauges.git (at master) 
Using jquery-rails (2.0.0) 
Using metaclass (0.0.1) 
Using minitest (2.11.2) 
Using mocha (0.10.4) 
Using mysql (2.8.1) 
Using sass (3.1.15) 
Using sass-rails (3.2.4) 
Using sqlite3 (1.3.5) 
Using turn (0.9.3) 
Using uglifier (1.2.3) 
Using whenever (0.7.3) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
ggrillone
  • 526
  • 1
  • 6
  • 20
  • can you post your gemfile? it might be as simple as adding `gem "json"` to your gemfile or `gem 'multi_json'` and running `bundle install` – Geoff Lanotte Jun 14 '12 at 17:44
  • ok, ya just posted it. Also, I already tried adding gem 'multi-json', '1.1.0' and kept getting the following message after bundle install: Could not find gem 'multi-json (= 1.1.0) ruby' in the gems available on this machine. – ggrillone Jun 14 '12 at 17:47
  • `gem "mutli_json"` with an underscore not a dash and don't put the version requirement on there just for testing. – Geoff Lanotte Jun 14 '12 at 17:50
  • Ok I put gem 'multi_json' in the Gemfile and ran bundle install, still getting the same error though :( – ggrillone Jun 14 '12 at 17:52
  • I'm not sure if this is causing the issue because I tried sending emails before without whenever and they were sent, but I'm just testing this on localhost:3000 – ggrillone Jun 14 '12 at 17:53
  • I just found this, might help you... http://stackoverflow.com/questions/10242219/why-i-am-getting-could-not-find-multi-json-1-3-1-in-any-of-the-sources – Geoff Lanotte Jun 14 '12 at 17:57
  • I also tried using specifying the version '1.1.0' and it still gave same error. I just tried the solution on the link you posted by deleting Gemfile.lock and running bundle install, but now it gives this error: Could not find activesupport-3.2.0 in any of the sources (Bundler::GemNotFound) – ggrillone Jun 14 '12 at 18:01
  • and when I run bundle install it does say: Using multi_json (1.1.0), maybe some sort of path issue? – ggrillone Jun 14 '12 at 18:12
  • This is somewhat odd, make sure you are running the most recent bundler `gem update bundler`. also try adding to the the source list with`source :rubygems` it is almost like it isn't seeing the remote gem repository. If that doesn't work, please append the full output when you run `bundle install` – Geoff Lanotte Jun 14 '12 at 20:52
  • what is the ruby version are you using? what is your platform means mac, linux or what? – AMIC MING Jun 14 '12 at 22:31
  • Tried that still no luck, same error message :( I'll post the bundle install output above. I am running ruby 1.9.3 (whenever does support this version) and I am running Mac OS X 10.7 – ggrillone Jun 14 '12 at 22:53
  • Didn't really change anything, but now getting the following error in the log file: Could not find activesupport-3.2.3 in any of the sources (Bundler::GemNotFound). I tried uninstalling 'whenever' and all associated files and starting from scratch, I also tried creating a basic app to eliminate extra code to test 'whenever', both cases gave same error, maybe it's an issue with the setup of my environment? – ggrillone Jun 15 '12 at 14:38
  • Are you using RVM? It seems that bundler is using one gemset and server is using another - you can list your gemsets with `rvm gemset list` -- in my case (Passenger on Apache) I was just after major update of Ruby, Rails, Gem, Rake & Bundler but Passenger wasn't notified. [This solved my problem](http://stackoverflow.com/a/8390671/1013138), maybe someone will connect it with localhost issue... (In case of localhost, isn't .rvmc file in root directory responsible for doing same thing as one in this link? Like: `rvm ` line or something?) – Jakub Naliwajek Jul 09 '12 at 14:25

1 Answers1

4

I've had similar issues on OS X. Mainly because of different versions of Ruby installed. Or the built-in version fighting with versions I've installed myself.

Things to check:

  1. type which ruby in a terminal
  2. does the output make sense with what you have installed?
  3. are you using any Ruby managers (like rvm or rbenv)?
  4. if so, check your paths in /.bash_profile or /.bashrc to see where they point. This link might help with installing and configuring rbenv.
  5. I use rbenv so I have this in my bash_profile before any other $PATH declarations to make sure it grabs those executables first:

    export PATH="$HOME/.rbenv/bin:$PATH"

  6. what does gem env say? Is it the right path?
  7. I run Ruby 1.9.3 locally but have to deal with 1.8.7 remotely because of issues with our hosting company so I have both versions installed locally. I forget to update the bundle install for the right version of Ruby command and scratch my head when I get errors like the one you are seeing. Hopefully you don't have this problem, but I'm just pointing it out in case it leads you down the right path.
  8. does bundle exec rails console or bundle exec rails server do the same thing as rails console and rails server respectively?
  9. If they don't, where are you installing the bundles? Simply bundle install or bundle install --path vendor/bundle?
Hopefully some of this will help you pinpoint the problem.

If you're getting desperate, remove the built-in version of Ruby and install a fresh version with either rvm or rbenv (I prefer rbenv after having lots of problems with rvm) and try again to see if that works.

kakubei
  • 5,321
  • 4
  • 44
  • 66