For those who are stuck with running cron jobs with Ruby scripts. The non-interactive shell “bash -lc” might not work. The sure shot way is to just export your path in the job itself.

You might be getting errors like these:

.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- ./formatter (LoadError)
/usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- nokogiri (LoadError)

The Fix

1 12 * * * export PATH="$HOME/.rbenv/bin:$PATH"; eval "$(rbenv init -)"; cd [location of app]; ruby [app].rb