≡ Menu

How to Force Install a Perl Module using CPAN

On an ongoing basis, I’ll be answering some of the questions asked by TGS readers. If you have any questions, use the contact form to get in touch with me.

The following question is from one of the regular readers of TGS.

Question: I’m trying to install a perl module using CPAN, and it displays “make test had returned bad status, won’t install without force”. How do I force install this CPAN module?

Answer: In the following example, when I was trying to install Net::SSLeay module, it didn’t get installed, as some of the test failed. By default, perl CPAN will not install a module when a test fails.

cpan> install Net::SSLeay

Failed Test                       Stat Wstat Total Fail  Failed  List of Failed
-------------------------------------------------------------------------------
t/local/61_threads-cb-crash.t      255 65280     1    0   0.00%  ??
t/local/62_threads-ctx_new-deadlo  255 65280     1    0   0.00%  ??

Failed 2/31 test scripts, 93.55% okay. 0/2706 subtests failed, 100.00% okay.

make: *** [test_dynamic] Error 255
  /usr/bin/make test -- NOT OK

Running make install
  make test had returned bad status, won't install without force

In this particular case, I know that I’m not too concerned about the specific test cases that failed. It is Ok with me to install the Net::SSLeay module even with these failed test cases.

In this case, I can use “force install” command as shown below to instruct cpan to install the module, despite the fact that some of the tests failed.

If the force install works, you’ll see “/usr/bin/make install — OK” as the last line in the output as shown below.

cpan> force install Net::SSLeay
..
/usr/bin/make install  -- OK

Note: Don’t blindly use force install. You should really research and see what test cases failed, and only if you are still Ok to install the perl module with those failed test cases, you should use force install.

Please note that you can also install a perl module manually without using CPAN.

Typically CPAN.pm tracks all that was done during installation, and will not perform the same activity when you try to do it again. For example, if you’ve already done get, or make, or test command for a module, if you try to do it again, CPAN will not perform those. In those scenarios, you can use “force” command.

For example, if you use get command for a module that CPAN already has in it’s build directory, it won’t perform the get again as shown below.

cpan> get XML::Simple
Running get for module XML::Simple
  Is already unwrapped into directory /root/.cpan/build/XML-Simple-2.20

For some reason, if you want to force the get, you can do it as shown below. In the same way, you can also use force with make and test command.

cpan> force get XML::Simple

fforce command is more forceful than force command.

fforce will do a force get to delete any data about this package from the local cpan cache, and start the get, make, test and install process from the beginning.

So, when you want to force install a package (assuming you know why you are doing this), you can do any one of the following:

cpan> force install Net::SSLeay

cpan> fforce install Net::SSLeay
Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • Sandy June 7, 2013, 1:03 pm

    Can I do force install from perl command line without having to interactively do this from the cpan> prompt?

    That will help me to automate my perl module installs from a shell script, when I know I need to perform force install.

  • Lokesh Jangir June 14, 2013, 8:21 am

    You can do it automate by perl command. If you want to install any module use below command-
    perl install-module.pl module_name

  • Kiri Kurukkal January 5, 2014, 9:14 am

    Hi Ramesh,

    Thanks for sharing this tip installing the Net::SSLeay with the force / fforce commands using cpan. Unfortunately, I wasn’t able to install this module using any of these commands. I am still getting the following error message.

    Running make install
    Make had returned bad status, install seems impossible
    Failed during this command:
    MIKEM/Net-SSLeay-1.55.tar.gz : make No

    Any suggestions that you can provide? I am using SUSE Linux 11 SP3. My original issue was that I was getting an error message Crypt-SSLeay can’t verify hostnames. After doing search on Google, I tried all of the suggested work arounds and nothing seems to work for me. I tried to reinstall the Crypt-SSLeay and also tried to install the Net-SSLeay and none of them are working. At this point, I have no idea what is causing this issue. Please let me know.

    Thanks,

    Kiri-