true has asked for the wisdom of the Perl Monks concerning the following question:

I installed ImageMagick+perl on my osx machine. It runs great from the shell with no errors. I have added a job to my crontab and the script fails saying "Image::Magick" is not found.

To find out where it is installed i shell "perldoc -l Image::Magick"
and get this "/opt/local/lib/perl5/site_perl/5.8.9/darwin-2level/"

so at the top of my perl script i add this...
use lib "/opt/local/lib/perl5/site_perl/5.8.9/darwin-2level/"

Still no luck.

Error is below

Can't load '/opt/local/lib/perl5/site_perl/5.8.9/darwin-2level//auto/I +mage/Magick/Magick.bundle' for module Image::Magick: dlopen(/opt/loca +l/lib/perl5/site_perl/5.8.9/darwin-2level//auto/Image/Magick/Magick.b +undle, 1): Symbol not found: _PL_curpad Referenced from: /opt/local/lib/perl5/site_perl/5.8.9/darwin-2level/ +/auto/Image/Magick/Magick.bundle Expected in: dynamic lookup at /Users/jtrue/wallpaper/cal.pl line 15 Compilation failed in require at /Users/jtrue/wallpaper/cal.pl line 15 +. BEGIN failed--compilation aborted at /Users/jtrue/wallpaper/cal.pl lin +e 15. &Image::Magick::constant not defined. The required ImageMagick librari +es are not installed or not installed properly. END failed--call queue aborted at /Users/jtrue/wallpaper/cal.pl line 1 +5.

Finally, i copied all of my @INC paths when run from shell and added each path manually (with a seperate use lib "PATH/HERE"; statement and it still fails.

Anyone have any ideas or suggestions?

P.S. My cron job is not run as root (i'd rather not do this).

jtrue

Replies are listed 'Best First'.
Re: Cron can't find a module in OSX
by Your Mother (Archbishop) on Sep 17, 2010 at 17:01 UTC

    Put the output of this (untested)-

    perl -le 'print q{PERL5LIB=}, join(":",grep /\w/, @INC)'

    -into the top of your crontab. That way it'll have access to everything you do on the command line. It's also possible you have more than one perl installed. If you do, make sure the shebang line refers to the one you want or you can also set it as an environment variable.

    (Update, corrected cut-off snippet.)

      print "$_ = $ENV{$_}\n" for grep /perl/i, keys %ENV;
Re: Cron can't find a module in OSX
by Anonymous Monk on Nov 03, 2010 at 20:46 UTC

    I'm having the same issue, however I'm trying to launch the script at startup and I prefer to use launchd (much as I like/use cron on Linux it's being phased out on Mac). So far I have included all the @INC paths and I am running my perl script from a bash script that contains the result of  perl -le 'print q{PERL5LIB=}, join(":",grep /w/, @INC)' (to try and obtain the equivalent effect of pasting it on top of the crontab). How can I make this work using launchd? I can use any instance of launchd /System/Library/LaunchAgent, /Library/LauncAgent, or ~/Library/LaunchAgent. I am currently using the latter and have not tried using the root ones ( and all of the testing is done using launchctl load without being root - though I don't see how this would make a difference ). My Mac is running Snow Leopard.

    Additional details follow.

    - Error output from launchd:

    Can't load '/opt/local/lib/perl5/5.8.9/darwin-2level/auto/Fcntl/Fcntl. +bundle' for module Fcntl: dlopen(/opt/local/lib/perl5/5.8.9/darwin-2l +evel/auto/Fcntl/Fcntl.bundle, 1): Symbol not found: _PL_curpad Referenced from: /opt/local/lib/perl5/5.8.9/darwin-2level/auto/Fcntl +/Fcntl.bundle Expected in: dynamic lookup at /opt/local/lib/perl5/5.8.9/darwin-2level/Fcntl.pm line 215 BEGIN failed--compilation aborted at /opt/local/lib/perl5/5.8.9/darwin +-2level/Fcntl.pm line 216. Compilation failed in require at /Users/rgr/wallpaper/cal.pl line 14. BEGIN failed--compilation aborted at /Users/rgr/wallpaper/cal.pl line +14.

    I've looked in the perl libraries for the source of the problem, darwin-2level/Fcntl.pm line 215:

    214 BEGIN { 215 XSLoader::load 'Fcntl', $VERSION; 216 }

    The Perl documentation concerning this error from XSLoader: " As the message says, some symbols stay undefined although the extension module was correctly loaded and initialised. The list of undefined symbols follows." (

    +bundle' for module Fcntl: dlopen(/opt/local/lib/perl5/5.8.9/darwin-2 +l +evel/auto/Fcntl/Fcntl.bundle, 1): Symbol not found: _PL_curpad
    ).

    I've opened darwin-2level/auto/Fcntl/Fcntl.bundle but it isn't human readable (save a few words here and there including _PL_curpad that I've searched).

    The Perl script I'm trying to run is a modified version of jtrue's excellent script to superpose a calendar on the desktop image.