3

I just got a new Mac and have been trying to setup a local development environment for my perl applications for a few days now with no luck. I'm getting no where fast so I hope someone else who has done this successfully could help.

I started by installing MAMP which I thought would take care of everything for me but unfortunately it doesn't take care of some important perl modules. I used CPAN to install all our required modules except that it seems DBD::mysql doesn't install correctly through CPAN. After reading a lot online, lots of people reported problems with this and recommended using MacPorts to install the module which I have tried doing with no luck using the following command:

sudo port install p5-dbd-mysql

After what seems like a successful install of DBD::mysql, Apache continues to report the following error when trying to run any of our Perl scripts:

[Fri Apr 30 18:51:07 2010] [error] [client 127.0.0.1] install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: /Library/Perl/Updates/5.10.0/darwin-thread-multi-2level /Library/Perl/Updates/5.10.0 /System/Library/Perl/5.10.0/darwin-thread-multi-2level /System/Library/Perl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0 /Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Network/Library/Perl/5.10.0 /Network/Library/Perl /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level /System/Library/Perl/Extras/5.10.0 .) at (eval 1835) line 3.
[Fri Apr 30 18:51:07 2010] [error] [client 127.0.0.1] Perhaps the DBD::mysql perl module hasn't been fully installed,
[Fri Apr 30 18:51:07 2010] [error] [client 127.0.0.1] or perhaps the capitalisation of 'mysql' isn't right.
[Fri Apr 30 18:51:07 2010] [error] [client 127.0.0.1] Available drivers: DBM, ExampleP, File, Gofer, Proxy, SQLite, Sponge.

I'm not sure where to go from here but my Mac isn't much of a development environment if Perl isn't able to talk to the database. I'd really appreciate any help and advice you might be able to provide in getting my system setup successfully. Thanks in advance!

1
  • With Macports did you install mysql before installing p5-dbd-mysql?
    – tegbains
    May 4, 2010 at 6:43

2 Answers 2

4

I've spent near 4 days fighting with this issue and here's the setup that finally got me there:

  • don't use macports
  • use the stock perl, with a twist:
    • Snow Leopard ships with 2 perls: 5.10.0 and 5.8.9 - switch to the earlier version like so:

% export VERSIONER_PERL_PREFER_32_BIT=yes

% defaults write com.apple.versioner.perl Prefer-32-Bit -bool yes

% defaults write com.apple.versioner.perl Version 5.8.9

  • download the 32bit version of mysql from dev.mysql.com/downloads/mysql/ ("Mac OS X ver. 10.6 (x86, 32-bit)")
    • Find the instructions on Google - I just put the extracted directory in /usr/local and linked /usr/local/mysql to that directory
  • CPAN seems to prefer the 5.10.0-specific install locations, so I downloaded DBD::mysql from search.cpan.org and did the usual install:

% perl Makefile.PL

% make

% sudo make install

UPDATE:

  • In order to get CPAN to get its config from the right perl version, and to get Apache to run perl CGIs with the right perl version, use the following command instead of the last one in the above list:

% defaults write /Library/Preferences/com.apple.versioner.perl Version 5.8.9

You'll have to be an admin to do this. After this, HUP apache and you'll be all set.

0

I've gone through the same headaches that Steve Ivy did, with the same solution.

In addition, because I'm using mod_perl2, I also had to build mod_perl manually -- if you download it from CPAN, then issue:

    $ cd ~/.cpan/build/mod_perl-2.*

    $ export ARCHFLAGS="-arch i386 -arch x86_64"
    $ export CFLAGS="-arch i386 -arch x86_64"

    $ perl Makefile.PL
            # (will prompt for where apxs is:
            /usr/sbin/apxs

    $ make -j8
            # make test will fail ... had to modify a file:

    $ vi t/response/TestAPI/access2.pm
            # around line 117, comment out the line:

            AuthGroupFile @DocumentRoot@/api/auth-groups

            # (I have no idea *why* this is failing, though)

    $ make test
            # in my case, it failed a couple of tests ... 5 out of 238
            # most were because we're running older versions of
            # modules, or the pure-perl varient (you'll see 'PP' in
            # the module name, or it complains about (something)XS)

            # If you're concerned, see t/logs/error_log

    $ sudo make install

... and then force Apache2 down to 32 bit, by following Michael Cramer's advice

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .