Working with missing Makefile.PL scripts in CPAN modules

Some versions of CPAN (notably, the one that ships with Red Hat / CentOS 4.6, v1.7601) will automatically attempt to create a ‘Makefile.PL’ script if a module you’re trying to install through CPAN is missing one. However, sometimes this may lead to an error during the module installation, usually something like: “Too early to specify a build action ‘Build’.  Do ‘Build Build’ instead.”. This appears to be caused by a missing argument to ExtUtils::MakeMaker’s WriteMakefile subroutine. If the ‘PL_FILES’ argument doesn’t exist, MakeMaker will incorrectly attempt to use the Build.PL file included with the module.

To fix this (using String::Random as an example), you’ll want to enter the cpan shell with ‘cpan’, then run ‘look String::Random’ to download the module, extract it, and get yourself a shell in the module directory. Edit Makefile.PL, and change the line that looks like: “WriteMakefile(NAME => q[StringRandom]);” to read “WriteMakefile(NAME => q[StringRandom], PL_FILES => {});”. After this, exit the shell you’re in to return to the cpan prompt, and then run ‘install String::Random’ to finish the install.

Leave a Reply

Your email address will not be published. Required fields are marked *