Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Fix "Can't locate CPAN.pm in @INC"

This guide shows how to fix a Perl error that says it cannot find CPAN.

Note: This guide needs root access, which is full control of the server. It is for VPS and dedicated server owners.

What does the error mean?

Perl is a programming language. Many server tools are written in it, including parts of cPanel. A Perl module is an add-on package that gives Perl extra skills.

CPAN is a huge online store of Perl modules. A tool called cpan downloads and installs them for you. The error means the CPAN tool itself is missing from your server.

The @INC part is the list of folders where Perl looks for modules. Perl checked every folder in that list and found no CPAN.pm file.

Step 1: See the problem

perl -MCPAN -e 'print "ok\n"'

This tries to load CPAN. If it prints "ok", it already works. If you get the same error, go on.

Step 2: Install CPAN with your package manager

On CentOS, AlmaLinux or Rocky Linux:

yum install perl-CPAN

This installs the CPAN tool. On newer systems, use dnf instead of yum.

On Ubuntu or Debian:

apt-get install perl-modules

On some Debian versions, the package is named cpanminus or libcpan-meta-perl. If the name is not found, search for it.

apt-cache search cpan

This lists packages with "cpan" in their name.

Step 3: Try it again

perl -MCPAN -e 'print "ok\n"'

Now it should print "ok". The first time you run cpan, it asks setup questions. Press Enter to accept the default answers.

On a cPanel server

cPanel keeps its own copy of Perl. Use the cPanel tool to install modules. It is in WHM under Module Installers, then Perl Modules. Or run this command.

/scripts/perlinstaller

This opens the cPanel Perl installer.

Tip: Do not copy files around by hand. A broken Perl can stop server tools from working.

Warning: Do not remove or replace the system Perl. Many tools depend on it.

Still stuck? Open a support ticket.

Quick recap

  • CPAN installs Perl add-on modules.
  • The error means the CPAN tool is not installed.
  • Install perl-CPAN with yum or dnf, or the matching package on Ubuntu.
  • On cPanel servers, use /scripts/perlinstaller.