If you see this error when cron job runs a ruby script:
'require': cannot load such file ...
And you are using bundler e.g. require 'bundler/setup'
. It's probably because the directory where cron runs the script is not correct, resulting in bundler fails to load gems.
Simply changed the directory to fix it, i.e.
* * * * * /usr/local/bin/ruby -C /home/example/scripts example_script.rb >>/home/example/log/cron.log 2>&1
Note -C
will Causes Ruby to switch to the directory.
.