4
votes

I'm getting Can't locate Config/YAML.pm in @INC (you may need to install the Config::YAML module) while running a perl script.

Can't locate Config/YAML.pm in @INC (you may need to install the Config::YAML module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at myperlscript line 8. BEGIN failed--compilation aborted at myperlscript line 8.

Line 8 of the script shows use Config::YAML;. I'm using Ubuntu and have installed the libdata-yaml-perl and libyaml-perl packages, but still am getting the same error. What else is needed?

2

2 Answers

5
votes

Config::YAML requires a different package. Install the libconfig-yaml-perl package and the problem will be fixed.

0
votes

As the error says, something is missing in @INC. If you do have the module installed (perldoc -l YAML::Tiny for example) it might be installed in a location that is not added to @INC (see How is Perl's @INC constructed? (aka What are all the ways of affecting where Perl modules are searched for?) for how it's constructed).

That means that there could be something wrong with environment variables: if for example PERL5LIB is not set (or not set correctly), it could also cause this error.

For example, if Perl is installed in /home/myusername/perl5, setting PERL5LIB="/home/myusername/perl5/lib/perl5" can fix this (e.g. in your ~/.profile, don't forget to log out and in).

For reference, here is what my Perl installation had autogenerated:

PATH="/home/myusername/perl5/bin${PATH:+:${PATH}}"; export PATH;
PERL5LIB="/home/myusername/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="/home/myusername/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"/home/myusername/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/home/myusername/perl5"; export PERL_MM_OPT;