0

Running a cron job via Whenever gem where rake "ts:index" is set to run at a certain frequency, the sphinx_index.log is returning an odd error (the only info in the log):

Your Ruby version is 1.9.3, but your Gemfile specified 2.2.3

if bundle exec rake ts:rebuild is run on the server manually, the process executes properly. (I have yet to test whether the indexing does actually occur and picks up changes). The Ubuntu server does have 2.2.3 installed, though it may have had 1.9.3 natively installed.

Why is this occurring and what is its consequence?

Jerome
  • 5,583
  • 3
  • 33
  • 76

2 Answers2

0

It sounds like cron isn't picking up your preferred Ruby version. If you're using RVM, then https://stackoverflow.com/a/24092907/54500 might be helpful? I'm not sure what's needed for other Ruby version managers.

Community
  • 1
  • 1
pat
  • 16,116
  • 5
  • 40
  • 46
  • As Murphy would have it, I am using rbenv. There are two avenues I've found that address this matter http://benscheirman.com/2013/12/using-rbenv-in-cron-jobs/ actually addresses the use case of whenever-driven jobs. https://relativkreativ.at/articles/running-ruby-scripts-from-within-a-cron-job-in-an-rbenv-environment has a straight to crontab DRY approach. For whatever flavour turns you on... I have tried second (appears to be functioning) and will then test the first. Thanks for the lead Pat! – Jerome Mar 09 '17 at 15:09
0

Pat's answer is the correct thread of investigation.

Ben Scheirman's solution works as described for applications using the whenever gem. To use the proper ruby versions, rbenv's shims folder needs to be declared to the PATH.

Jerome
  • 5,583
  • 3
  • 33
  • 76