bundler snippets

Running (and debugging) cronjobs with rbenv and bundler

Tagged rbenv, backup, cron, bundler  Languages bash

This snippet shows how to run a backup script (Backup gem) and how to debug cron in case it doesn't work.

This example uses bundler and rbenv to complicate things:

# Set the path to include rbenv
PATH=$PATH:/home/xxx/.rbenv/shims/:/home/xxx/.rbenv/bin/:/bin:/usr/bin/

# Debug cron environment...
*/1 * * * * /bin/bash -l -c '/bin/env > /tmp/cron-env.log'

# Run backup every 12 hours
* */12 * * * /bin/bash -l -c 'eval "$(rbenv init -)" && cd /var/www/xxx/current && bundle exec backup perform --trigger xxx -c config/backup.rb >> /tmp/backup.log 2>&1'

If backup fails, check /tmp/backup.log and/or /tmp/cron-env.log.

No "bundle exec"

Tagged bundler, bundle exec  Languages ruby

If RubyGems >= 2.2.0:

export RUBYGEMS_GEMDEPS=-

else:

https://github.com/mpapis/rubygems-bundler

Install missing gem executables with `bundle install`

Tagged bundler, rails, rubygems, ruby  Languages bash

When:

$ bundle exec cucumber

bundler: command not found: cucumber
Install missing gem executables with `bundle install`

Do:

$ rm .bundle/config # remove a broken bundler configuration
$ gem update --system # might help if rubygems is outdated / broken
$ gem update bundler # might help if bundler is outdated / broken
$ bundle install # dependency hell

Or, start using, e.g., golang, crystal, etc.