* [gentoo-user] Postgres gem not found by cron job
@ 2010-08-11 18:17 Michael Orlitzky
2010-08-11 19:16 ` Bill Longman
0 siblings, 1 reply; 4+ messages in thread
From: Michael Orlitzky @ 2010-08-11 18:17 UTC (permalink / raw
To: gentoo-user
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?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] Postgres gem not found by cron job
2010-08-11 18:17 [gentoo-user] Postgres gem not found by cron job Michael Orlitzky
@ 2010-08-11 19:16 ` Bill Longman
2010-08-11 19:32 ` Michael Orlitzky
0 siblings, 1 reply; 4+ messages in thread
From: Bill Longman @ 2010-08-11 19:16 UTC (permalink / raw
To: gentoo-user
<snip>
> 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?
No direct answer, sorry, Michael.
You might want to use:
/bin/bash -l -x -c /root/src/mailshears/bin/mailshears
to at least help debug it.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] Postgres gem not found by cron job
2010-08-11 19:16 ` Bill Longman
@ 2010-08-11 19:32 ` Michael Orlitzky
2010-08-13 18:36 ` [gentoo-user] " Hans de Graaff
0 siblings, 1 reply; 4+ messages in thread
From: Michael Orlitzky @ 2010-08-11 19:32 UTC (permalink / raw
To: gentoo-user
On 08/11/2010 03:16 PM, Bill Longman wrote:
> <snip>
>> 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?
>
> No direct answer, sorry, Michael.
>
> You might want to use:
>
> /bin/bash -l -x -c /root/src/mailshears/bin/mailshears
>
> to at least help debug it.
>
Thanks for the tip. The cron environment was missing
"RUBYOPT=-rauto_gem" -- adding it fixed the problem.
Dark magic, whatever it does.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [gentoo-user] Re: Postgres gem not found by cron job
2010-08-11 19:32 ` Michael Orlitzky
@ 2010-08-13 18:36 ` Hans de Graaff
0 siblings, 0 replies; 4+ messages in thread
From: Hans de Graaff @ 2010-08-13 18:36 UTC (permalink / raw
To: gentoo-user
On Wed, 11 Aug 2010 15:32:53 -0400, Michael Orlitzky wrote:
> Thanks for the tip. The cron environment was missing
> "RUBYOPT=-rauto_gem" -- adding it fixed the problem.
>
> Dark magic, whatever it does.
It ensures that installed gems are found automatically without
specifying this explicitly in your script. The other solution
is to "require 'rubygems'" first in your script.
Kind regards,
Hans
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-08-13 19:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-11 18:17 [gentoo-user] Postgres gem not found by cron job Michael Orlitzky
2010-08-11 19:16 ` Bill Longman
2010-08-11 19:32 ` Michael Orlitzky
2010-08-13 18:36 ` [gentoo-user] " Hans de Graaff
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox