1 |
I feel like I should be able to solve this one, but it started after my |
2 |
last world update so maybe someone else has had a similar problem. |
3 |
|
4 |
We have a ruby script called 'mailshears' on our mail server that cleans |
5 |
up orphaned users and domains every night. The main script, |
6 |
|
7 |
/root/src/mailshears/bin/mailshears |
8 |
|
9 |
includes a class, |
10 |
|
11 |
require 'src/postfixadmin_db' |
12 |
|
13 |
which in turn requires the postgres library from ruby-postgres: |
14 |
|
15 |
require 'postgres' |
16 |
|
17 |
I don't think there's anything fancy going on here. All of the required |
18 |
packages are installed, and the script runs fine when I execute it |
19 |
manually. For example, both of the following work: |
20 |
|
21 |
cd /root/src/mailshears/bin/ |
22 |
./mailshears |
23 |
|
24 |
cd / |
25 |
export PATH=/sbin:/bin:/usr/sbin:/usr/bin |
26 |
export HOME=/ |
27 |
/root/src/mailshears/bin/mailshears |
28 |
|
29 |
(That last one mimics my crontab.) The problem is, whenever the nightly |
30 |
cron job runs, the 'postgres' library can't be found. I get mailed this |
31 |
every night: |
32 |
|
33 |
/root/src/mailshears/bin/../src/postfixadmin_db.rb:1:in `require': no |
34 |
such file to load -- postgres (LoadError) |
35 |
from /root/src/mailshears/bin/../src/postfixadmin_db.rb:1 |
36 |
from /etc/cron.daily/01mailshears:35:in `require' |
37 |
from /etc/cron.daily/01mailshears:35 |
38 |
|
39 |
The path /etc/cron.daily/01mailshears is simply a symlink to |
40 |
/root/src/mailshears/bin/mailshears, and of course, if I execute that |
41 |
symlink manually, it runs fine. |
42 |
|
43 |
What's different between my root environment and the one in which cron |
44 |
runs (with respect to ruby and its gems)? Where should I start looking? |