Skip to content

Cannot locate Getopt Long.pm in @INC error in CentOS 8: Resolved

Updated 2 min read

Updated: 11 October 2026 · Applies to: AlmaLinux 9 / Rocky Linux 9

The message Can't locate Getopt/Long.pm in @INC means a Perl script needs the Getopt::Long module, which is not installed. Minimal installations of AlmaLinux 9 / Rocky Linux 9 do not include all Perl modules.

Fix

dnf install 'perl(Getopt::Long)'      # AlmaLinux / Rocky: installs perl-Getopt-Long
apt install perl                       # Ubuntu / Debian: full set of core modules

The same pattern works for any missing module: the file Foo/Bar.pm is the module Foo::Bar, so install 'perl(Foo::Bar)'. To install the complete standard Perl on AlmaLinux/Rocky at once, use dnf install perl.

Check

perl -MGetopt::Long -e 'print "ok\n"'

If a module is not packaged, see "How to build Perl module rpm file with cpanspec on RHEL/CentOS Linux?" or install it for your user with cpanm and local::lib.

Why it happens

Perl looks for modules in the folders listed in @INC (see them with perl -V). On AlmaLinux and Rocky Linux the Perl interpreter is split into many small packages, and a minimal installation contains only perl-interpreter and a few modules. Scripts written for a full Perl installation then stop at the first missing module. After installing it, run the script again: if another module is missing, the error names it and you install it the same way.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Linux server management

hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.

Was this answer helpful?

Still stuck? Open a ticket