1

I am trying to write a small program in perl which uses the MP3::Tag module. The program doesn't execute and gives me:

Can't locate MP3/Tag.pm in @INC (you may need to install the MP3::Tag module) (@INC contains: ... .) at mp3Editor.pl line 3.

where line 3 is: use MP3::Tag;

So then I try the command: cpan MP3::Tag

but I get: Warning: Cannot install MP3::Tag, don't know what it is.

I've downloaded the module from CPAN's website, however I can't seem to get it working. What must I do to get MP3::Tag module working on my system? Any help is appreciated. Thank you.

EDIT env | grep -i perl produces:

PERL_MB_OPT=--install_base "/home/bronson/perl5"
PERL_MM_OPT=INSTALL_BASE=/home/bronson/perl5
OxenMeat
  • 50
  • 1
  • 8
  • Try using [`cpanm`](https://github.com/miyagawa/cpanminus) instead, it is a far more user friendly CPAN client than `cpan`. – Schwern Mar 09 '16 at 01:29
  • `cpanm` seems to have at least done something. I still get the same issue when trying to run the program itself though. – OxenMeat Mar 09 '16 at 01:33
  • 1
    Then you probably have multiple copies of Perl installed. Your program is using one, and cpanm is installing to another. cpanm will use whatever Perl is in your PATH, check with `which perl` and check that against your `#!` line at the top of your program. – Schwern Mar 09 '16 at 01:35
  • They are both usr/bin/perl . But I think you're right. I noticed I have a perl5 with mp3 stuff in it located in my documents somewhere. How could I change this or move it? – OxenMeat Mar 09 '16 at 01:41
  • That's odd. Check `which cpanm` and see if that's coming from somewhere odd. I'd also check `env | grep -i perl` to see if any environment variables affecting installation are set. – Schwern Mar 09 '16 at 01:42
  • `which cpanm` is `usr/bin/cpanm` ... `env | grep -i perl` is my perl5 in some random documents – OxenMeat Mar 09 '16 at 01:45
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/105748/discussion-between-schwern-and-oxenmeat). – Schwern Mar 09 '16 at 01:46
  • You might not have the rep for chat. All that perl stuff in your environment is likely what is causing the problem. If you the output of `env | grep -i perl` to your question then people might be able to help. – Schwern Mar 09 '16 at 01:48
  • Possible duplicate of [What's the easiest way to install a missing Perl module?](http://stackoverflow.com/questions/65865/whats-the-easiest-way-to-install-a-missing-perl-module) – Oleg V. Volkov Mar 09 '16 at 14:03

1 Answers1

1

It seems your cpan client is misconfigured, it doesn't seem to have a proper list of CPAN modules. cpanm is a more user friendly CPAN client than cpan, I recommend using it instead.

If a freshly installed cpanm installs the module but you're still getting the error, and if which perl and the Perl in your #! line are the same, then your modules are probably getting installed outside the standard Perl library locations. There's a few ways this could happen, the first is to check for environment variables affecting your installation. env | grep -i perl is a good start. Things like PERL_MB_OPT and PERL_MM_OPT will alter how cpan and cpanm call the Build.PL and Makefile.PL installers.

If PERL_M*_OPT are set then there should be a corresponding PERL5LIB to tell Perl to look in the non-standard location for those modules.

This is usually done to allow non-root users to install modules into their home directory.

In your case you seem to have PERL_M*_OPT set but no PERL5LIB. You'll need to set PERL5LIB to where ever the modules got installed, probably /home/bronson/perl5/lib/perl5/.


This can all get a bit hairy. There's two tools to make this easier.

First is Perlbrew. It installs Perl in your home directory and configures everything for you. It can even support multiple versions. This is the simplest and recommended way to develop Perl. It gives you full control over the Perl installation, you're not tied to what the system has installed.

The other is to use local::lib to manage your Perl environment. It will help you set Perl environment variables to install Perl modules to your home directory and use them. You might have a mangled version of that right now.

Schwern
  • 153,029
  • 25
  • 195
  • 336