I feel like I should be able to solve this one, but it started after my last world update so maybe someone else has had a similar problem.

We have a ruby script called 'mailshears' on our mail server that cleans up orphaned users and domains every night. The main script,

  /root/src/mailshears/bin/mailshears

includes a class,

  require 'src/postfixadmin_db'

which in turn requires the postgres library from ruby-postgres:

  require 'postgres'

I don't think there's anything fancy going on here. All of the required packages are installed, and the script runs fine when I execute it manually. For example, both of the following work:

  cd /root/src/mailshears/bin/
  ./mailshears

  cd /
  export PATH=/sbin:/bin:/usr/sbin:/usr/bin
  export HOME=/
  /root/src/mailshears/bin/mailshears

(That last one mimics my crontab.) The problem is, whenever the nightly cron job runs, the 'postgres' library can't be found. I get mailed this every night:

  /root/src/mailshears/bin/../src/postfixadmin_db.rb:1:in `require': no
  such file to load -- postgres (LoadError)
        from /root/src/mailshears/bin/../src/postfixadmin_db.rb:1
        from /etc/cron.daily/01mailshears:35:in `require'
        from /etc/cron.daily/01mailshears:35

The path /etc/cron.daily/01mailshears is simply a symlink to /root/src/mailshears/bin/mailshears, and of course, if I execute that symlink manually, it runs fine.

What's different between my root environment and the one in which cron runs (with respect to ruby and its gems)? Where should I start looking?

Reply via email to