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