Problems with running Ruby scripts as a cron job

software development

#1

Hi All,

I currently have a set of Ruby scripts that scrape some web sites for information and run them as a cron job on my dreamhost instance. However, whenever the scripts execute, I get the following error:

/usr/lib/ruby/1.8/rubygems.rb:777:in `report_activate_error': Could not find RubyGem json_pure (>= 1.1.7) (Gem::LoadError)
	from /usr/lib/ruby/1.8/rubygems.rb:211:in `activate'
	from /usr/lib/ruby/1.8/rubygems.rb:246:in `activate'
	from /usr/lib/ruby/1.8/rubygems.rb:245:in `each'
	from /usr/lib/ruby/1.8/rubygems.rb:245:in `activate'
	from /usr/lib/ruby/1.8/rubygems.rb:246:in `activate'
	from /usr/lib/ruby/1.8/rubygems.rb:245:in `each'
	from /usr/lib/ruby/1.8/rubygems.rb:245:in `activate'
	from /usr/lib/ruby/1.8/rubygems.rb:246:in `activate'
	from /usr/lib/ruby/1.8/rubygems.rb:245:in `each'
	from /usr/lib/ruby/1.8/rubygems.rb:245:in `activate'
	from /usr/lib/ruby/1.8/rubygems/custom_require.rb:35:in `require'
	from ./scripts/lib/carson_daly_scraper.rb:1
	from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from scripts/download_schedules:12

None of my scripts use or depend on json_pure and even when I install the gem, the cron job is unable to find it.

Any thoughts?

For more information about the problem, I also posted this question to StackOverflow:

http://stackoverflow.com/questions/10939906/how-to-find-json-pure-gem-when-a-cron-job-on-dreamhost-runs


#2

Have you seen the “Execution Enviroment” section of http://wiki.dreamhost.com/Cron ?


#3

Thanks for the link, I read through it and updated my scripts accordingly.

Unfortunately, I found another problem. When I try to use IRB to check if I can require json_pure, the command fails. None of my code requires this gem, why is Dreamhost’s cron job trying to include it?


#4

Hey.
Im having a similar problem with MySQL not loading after dreamhost updated my VPS os to Debian / linux(?)
im getting this error in all of my Cronjobs (all of which worked fine before the OS update)

Ive been pulling my hair out trying to fix this… any help would be SUPER appreciated!

!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
/home/username/.gem/ruby/1.8/gems/rails-2.3.8/lib/commands/runner.rb:48: /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’: no such file to load – mysql (MissingSourceFile)