Skip to main content
Background Image
  1. Posts/

Run lcov failed "Can't locate JSON/PP.pm in @INC ..."

·403 words·2 mins· ·
Xianpeng Shen
Author
Xianpeng Shen
Table of Contents

When execute command: lcov --capture --directory . --no-external --output-file coverage.info to generate code coverage report, I encountered the following error:

$ lcov --capture --directory . --no-external --output-file coverage.info
Capturing coverage data from .
Can't locate JSON/PP.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/bin/geninfo line 63.
BEGIN failed--compilation aborted at /usr/local/bin/geninfo line 63.
sh-4.2$ perl -MCPAN -e 'install JSON'
Can't locate CPAN.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).
BEGIN failed--compilation aborted.

Can’t locate CPAN.pm
#

fixed this problem “Can’t locate CPAN.pm” by running the command yum install perl-CPAN

sh-4.2$ sudo perl -MCPAN -e 'install JSON'
[sudo] password for sxp:
Can't locate CPAN.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).
BEGIN failed--compilation aborted.
sh-4.2$ sudo yum install perl-CPAN

Then run sudo perl -MCPAN -e 'install JSON' again, it works.

Can’t locate JSON/PP.pm
#

fixed this problem by copying backportPP.pm to the PP.pm file.

$ cd /usr/local/share/perl5/JSON
$ ls
backportPP  backportPP.pm
$ cp backportPP.pm PP.pm

Can’t locate Module/Load.pm
#

bash-4.2$ geninfo --version
Can't locate Module/Load.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/bin/geninfo line 63.
BEGIN failed--compilation aborted at /usr/local/bin/geninfo line 63.
bash-4.2$

Install perl-Module-Load-Conditional can resolved.

sudo yum install perl-Module-Load-Conditional

Can’t locate Capture/Tiny.pm in @INC
#

sh-4.2$ lcov --version
Can't locate Capture/Tiny.pm in @INC (@INC contains: /usr/local/bin/../lib /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/bin/../lib/lcovutil.pm line 13.
BEGIN failed--compilation aborted at /usr/local/bin/../lib/lcovutil.pm line 13.
Compilation failed in require at /usr/local/bin/lcov line 104.
BEGIN failed--compilation aborted at /usr/local/bin/lcov line 104.

Fixed with following command

perl -MCPAN -e 'install Capture::Tiny'

Then run lcov --version back to work.

sh-4.2$ lcov --version
lcov: LCOV version v1.16-16-g038c2ca

Can’t locate DateTime.pm
#

$ genhtml --help
Can't locate DateTime.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/bin/genhtml line 87.
BEGIN failed--compilation aborted at /usr/local/bin/genhtml line 87.

Need to install the perl module DateTime, On Centos7 run

sudo yum install 'perl(DateTime)'

But this still doesn’t work for me.

Run geninfo command failed
#

Capturing coverage data from .
Compress::Raw::Zlib version 2.201 required--this is only version 2.061 at /usr/local/share/perl5/IO/Uncompress/RawInflate.pm line 8.
BEGIN failed--compilation aborted at /usr/local/share/perl5/IO/Uncompress/RawInflate.pm line 8.
Compilation failed in require at /usr/local/share/perl5/IO/Uncompress/Gunzip.pm line 12.
BEGIN failed--compilation aborted at /usr/local/share/perl5/IO/Uncompress/Gunzip.pm line 12.
Compilation failed in require at /usr/local/bin/geninfo line 62.
BEGIN failed--compilation aborted at /usr/local/bin/geninfo line 62.
sh-4.2$

Install package Compress::Raw::Zlib fixed.

perl -MCPAN -e 'install Compress::Raw::Zlib'

Related

SonarQube installation and troubleshootings
·959 words·5 mins
This article documents the steps to install SonarQube, configure LDAP, and set up PostgreSQL as the database. It also includes troubleshooting tips for common issues encountered during setup.
How to fix "hidden symbol `__gcov_init' in ../libgcov.a(_gcov.o) is referenced by DSO"
·323 words·2 mins
This article explains how to resolve the “hidden symbol `__gcov_init’ in ../libgcov.a(_gcov.o) is referenced by DSO” error when building a project with Gcov, including how to ensure symbols are not hidden.
Add or update Bitbucket build status with REST API
·182 words·1 min
How to add or update the build status of a specific commit in Bitbucket using its REST API. It includes a shell script example for updating the build status and provides context on when to use this functionality.
Code coverage testing of C/C++ projects using Gcov and LCOV
·1000 words·5 mins
This article shares how to use Gcov and LCOV to metrics code coverage for C/C++ projects. It explains the steps to compile, run tests, and generate coverage reports, including example commands and expected outputs.
How to make Jenkins job fail after timeout? (Resolved)
·208 words·1 min
This article explains how to handle Jenkins job timeouts effectively by using try and catch blocks to ensure the job fails correctly when a timeout occurs.
Resolved problem that ESlint HTML report is not displayed correctly in Jenkins job
·159 words·1 min
This article explains how to resolve the issue of ESlint HTML report not displaying correctly in Jenkins jobs due to Content Security Policy restrictions, including the steps to configure Jenkins to allow the report to load properly.