Coding⏱️ 4 min read📅 2026-06-03

How to Fix: What's the easiest way to install a missing Perl module?

Install missing Perl module with CPAN.

Quick Answer: Use the CPAN (Comprehensive Perl Archive Network) tool to easily install the required Perl module.

The error message 'Can't locate Foo.pm in @INC' indicates that the Perl module Foo::Foo is not found by the system. This issue can occur when the module is not installed or not available in the system's Perl library path, known as '@INC'. The user is likely a Perl developer who needs to use this module for their project.

Installing Perl modules can be time-consuming and tedious, especially when dealing with CPAN (Comprehensive Perl Archive Network) packages. However, there are easier ways to install missing Perl modules than downloading, untarring, making, etc.

⚠️ Common Causes

  • The primary reason why the error 'Can't locate Foo.pm in @INC' occurs is that the module Foo::Foo is not installed or not available in the system's Perl library path. This can happen if the user has not installed the required modules for their project or if the CPAN installation is corrupted.
  • Alternatively, the issue might be due to a misconfigured CPAN shell or an incorrect configuration of the Perl environment.

✅ Best Solutions to Fix It

Using CPAN to Install the Module

  1. Step 1: Open a terminal or command prompt and navigate to the directory where you want to install the module. Type 'cpanm Foo::Foo' (assuming you have the 'cpanm' command available) or 'cpan Foo::Foo' if you prefer the older 'cpan' interface.
  2. Step 2: If prompted, enter your CPAN password and wait for the installation to complete. This may take several minutes depending on the size of the module and the speed of your connection.
  3. Step 3: Once the installation is complete, verify that the module has been successfully installed by running 'perl -M Foo::Foo -e 'print $Foo::Foo::VERSION;'

Using cpanm with a Local Mirror

  1. Step 1: First, configure your CPAN shell to use a local mirror. This can be done by adding the following lines to your ~/.cpan/META/RECOMMENDATIONS/CPANMORE.conf file:
  2. Step 2: Add the following line at the end of the file: cpanm::Foo::Foo (local mirror) = ftp://your.local.mirror.com/Foo-Foo-1.0.tar.gz
  3. Step 3: Then, run 'cpanm Foo::Foo' to install the module from your local mirror.
  4. Step 4: Note that this method requires you to have a local mirror of the CPAN package available.

💡 Conclusion

To resolve the error 'Can't locate Foo.pm in @INC', try using one of the two primary fix methods: (1) Using CPAN to install the module, or (2) Using cpanm with a local mirror. If you encounter any issues during installation, refer to the CPAN documentation and online forums for further assistance.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions