script/runner + cron job = sad rmagick

Hi,

I’m running a cron job to parse some RSS feeds. When running the following from the terminal everything works as expected:

antrover:~/Sway/Projects/mi7/trunk/mi7 dave$ script/runner -e development "
GetRssData.find_and_parse"
Loaded suite script/runner
Started
Finished in 0.001333 seconds.
0 tests, 0 assertions, 0 failures, 0 errors

However, when setting up the cron job:

*/20 * * * * ~/Sway/Projects/mi7/trunk/mi7/script/runner -e development "
GetRssData.find_and_parse"

I get the following RMagick error:

/Users/dave/Sway/Projects/mi7/trunk/mi7/script/…/config/…/vendor/rails/railties/lib/commands/runner.rb:27: /Users/dave/Sway/Projects/mi7/trunk/mi7/script/…/config/…/vendor/rails/activerecord/lib/…/…/activesupport/lib/active_support/dependencies.rb:147:in `require’: No such file to load – RMagick (MissingSourceFile)

    from /Users/dave/Sway/Projects/mi7/trunk/mi7/script/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:147:in `require'
    from /Users/dave/Sway/Projects/mi7/trunk/mi7/script/../config/../vendor/plugins/file_column/lib/validations.rb:95:in `validates_image_size'

    from /Users/dave/Sway/Projects/mi7/trunk/mi7/script/../config/../app/models/member.rb:125
    from /Users/dave/Sway/Projects/mi7/trunk/mi7/script/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:140:in `load'

    from /Users/dave/Sway/Projects/mi7/trunk/mi7/script/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:140:in `load'
    from /Users/dave/Sway/Projects/mi7/trunk/mi7/script/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:56:in `rails_pre_engines_require_or_load'

    from /Users/dave/Sway/Projects/mi7/trunk/mi7/script/../config/../vendor/plugins/engines/lib/engines/dependencies_extensions.rb:60:in `rails_1_1_require_or_load'
    from /Users/dave/Sway/Projects/mi7/trunk/mi7/script/../config/../vendor/plugins/engines/lib/engines/dependencies_extensions.rb:14:in `require_or_load'

     ... 11 levels...
    from /Users/dave/Sway/Projects/mi7/trunk/mi7/script/runner:3:in `eval'
    from /Users/dave/Sway/Projects/mi7/trunk/mi7/script/../config/../vendor/rails/railties/lib/commands/runner.rb:27

    from /Users/dave/Sway/Projects/mi7/trunk/mi7/script/runner:3:in `require'
    from /Users/dave/Sway/Projects/mi7/trunk/mi7/script/runner:3

Why is it saying “No such file to load – RMagick (MissingSourceFile)”?

Is there a way to ignore validations? My Member model does use rmagick when uploading files.

I have frozen the project at 1.1.6

This is what get_rss_data.rb looks like:

class GetRssData
def self.find_and_parse
feeds_to_parse = MemberRssUrl.find(:all)
for feed in feeds_to_parse
member = Member.find(feed.member_id)
ExternalFeedTools.new(feed.rss_url, member).parse_feed
end

end
end

ExternalFeedTools just parses the items out of the actual feed using ‘FeedTools’. Nothing exciting going on there.

I’ve been using rmagick on my Powerbook for awhile (1.5 + years) and this is the first problem I’ve ever encountered.

Any ideas?

Thanks!
-Dave

The environment running cron seems to not know about gems. Check that the cron user can properly run ruby scripts / has access to use gems.

Jason