1

When generating tasks via the whenever gem, the resulting line in cron format looks something like this:

0 13 30 * * /bin/bash -l -c 'cd $OPENSHIFT_REPO_DIR && bin/rails runner -e production "puts \"test\""'

Now, when I SSH into the OpenShift app and try to execute that bash command for testing purposes, I get an error:

# /bin/bash -l -c 'cd $OPENSHIFT_REPO_DIR && bin/rails runner -e production'
/opt/rh/ruby200/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:53:in `require': cannot load such file -- bundler/setup (LoadError)
        from /opt/rh/ruby200/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:53:in `require'
        from /var/lib/openshift/$APP_ID/app-root/runtime/repo/config/boot.rb:6:in `<top (required)>'
        from /opt/rh/ruby200/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:53:in `require'
        from /opt/rh/ruby200/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:53:in `require'
        from bin/rails:9:in `<main>'

How can I ensure the bin/rails runner command to actually execute correcty?

user569825
  • 2,369
  • 1
  • 25
  • 45

1 Answers1

2

Try

/bin/bash -l -c 'cd $OPENSHIFT_REPO_DIR && bundle exec bin/rails runner -e production'

So that it will use your bundled gems when running the commands.