Fixed: CPAN failed with "Undefined subroutine &Compress::Zlib::gzopen…

For some unknown reasons, CPAN on my macbook suddenly stopped working.  This is the error I got whenever I tried to use CPAN to install a module:

Catching error: "Undefined subroutine &Compress::Zlib::gzopen called at /Library/Perl/Updates/5.8.8/CPAN/Tarzip.pm line 122.\cJ" at /Library/Perl/Updates/5.8.8/CPAN.pm line 390
CPAN::shell() called at /usr/bin/cpan line 198

I found a lot of suggestions from googling for it. The best solution for my case was to remove all Compress::Zlib (Zlib.pm) from every perl libraries, manually and re-install a new one.

‘perl -V’ will give you a list of a libraries in the @INC variable.  Here’s an example of output:

adaud-MacBookPro:~ adaud$ perl -V
Summary of my perl5 (revision 5 version 8 subversion 9) configuration:  Built under darwin
...
  Compiled at Jul 10 2010 21:58:27
  @INC:
    /opt/local/lib/perl5/site_perl/5.8.9/darwin-2level
    /opt/local/lib/perl5/site_perl/5.8.9
    /opt/local/lib/perl5/site_perl
    /opt/local/lib/perl5/vendor_perl/5.8.9/darwin-2level
    /opt/local/lib/perl5/vendor_perl/5.8.9
    /opt/local/lib/perl5/vendor_perl
    /opt/local/lib/perl5/5.8.9/darwin-2level
    /opt/local/lib/perl5/5.8.9

Now you can manually search for the Zlib.pm by running the following:

'find /opt/local/lib/perl5 -name Zlib.pm -print"

Delete all that the find command does find.

0 comments ↓

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment