miyagawa / cpanminus

cpanminus - get, unpack, build and install modules from CPAN
http://cpanmin.us
746 stars 213 forks source link

Installing Music::Tag::MP3 fails with "Missing version info for module 'MP3::Tag'" right after installing MP3::Tag #661

Closed jonathancast closed 1 year ago

jonathancast commented 1 year ago

The command and output are:

$ cpanm -l local-lib/ Music::Tag::MP3@0.4101
--> Working on Music::Tag::MP3
Fetching http://www.cpan.org/authors/id/E/EA/EALLENIII/Music-Tag-MP3-0.4101.tar.gz ... OK
Configuring Music-Tag-MP3-0.4101 ... OK
==> Found dependencies: MP3::Tag
--> Working on MP3::Tag
Fetching http://www.cpan.org/authors/id/I/IL/ILYAZ/modules/MP3-Tag-1.16.zip ... OK
Configuring MP3-Tag-1.16 ... OK
Building and testing MP3-Tag-1.16 ... OK
Successfully installed MP3-Tag-1.16
! Installing the dependencies failed: Missing version info for module 'MP3::Tag'
! Bailing out the installation for Music-Tag-MP3-0.4101.
1 distribution installed

When I look for the version info in MP3::Tag manually I see:

$ grep VERSION local-lib/lib/perl5/MP3/Tag.pm 
use vars qw/$VERSION @ISA/;
$VERSION="1.16";
  mpeg_version          VERSION

$ which perl
/home/jcast/perl5/perlbrew/perls/perl-5.26.1/bin/perl
$ which cpanm
/home/jcast/perl5/perlbrew/bin/cpanm

$ env | grep -i perl
PERLBREW_PATH=/home/jcast/perl5/perlbrew/bin:/home/jcast/perl5/perlbrew/perls/perl-5.26.1/bin
PERLBREW_HOME=/home/jcast/.perlbrew
PERLBREW_SHELLRC_VERSION=0.86
MANPATH=/home/jcast/perl5/perlbrew/perls/perl-5.26.1/man:/home/jcast/sys/node-v16.17.0-linux-x64/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man:/home/jcast/plan9/man
PERLBREW_PERL=perl-5.26.1
PERLBREW_VERSION=0.86
PATH=/home/jcast/perl5/perlbrew/bin:/home/jcast/perl5/perlbrew/perls/perl-5.26.1/bin:/home/jcast/.ghcup/bin:/home/jcast/.jbang/bin:/home/jcast/.cabal/bin:/home/jcast/sys/android-studio/bin:/home/jcast/sys/micropolis/bin:/home/jcast/sys/freeciv/bin:/home/jcast/sys/bin:/home/jcast/sys/apache-maven-3.8.4/bin:/home/jcast/sys/node-v16.17.0-linux-x64/bin:/home/jcast/.cargo/bin:/home/jcast/bin:/home/jcast/sys/apache-maven-3.8.4/bin:/home/jcast/sys/node-v16.17.0-linux-x64/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/jcast/bin:/home/jcast/plan9/bin:/home/jcast/sys/nim-1.2.6/bin
PERLBREW_ROOT=/home/jcast/perl5/perlbrew
PERLBREW_MANPATH=/home/jcast/perl5/perlbrew/perls/perl-5.26.1/man
miyagawa commented 1 year ago

This is because Module::Metadata (used internally in CPAN::Meta::Check) is confused by the way $VERSION is defined in MP3/Tag.pm.

➜  perl -MModule::Metadata -e '$d=Module::Metadata->new_from_module("MP3::Tag", inc => ["./local-lib/lib/perl5"]); use Data::Dumper; warn Dumper $d'
$VAR1 = bless( {
                 'decode_pod' => undef,
                 'pod' => {},
                 'inc' => [
                            './local-lib/lib/perl5'
                          ],
                 'version' => undef,
                 'pod_headings' => [
                                     'NAME',
                                     'SYNOPSIS',
                                     'AUTHORS',
                                     'DESCRIPTION',
                                     'ENVIRONMENT',
                                     'CUSTOMIZATION',
                                     'EXAMPLE SCRIPTS',
                                     'Problems with ID3 format',
                                     'FILES',
                                     'SEE ALSO',
                                     'COPYRIGHT'
                                   ],
                 'filename' => '/private/tmp/local-lib/lib/perl5/MP3/Tag.pm',
                 'packages' => [
                                 'MP3::Tag',
                                 'MP3::Tag::__hasparent',
                                 'MP3::Tag::Implemenation',
                                 'MP3::Tag::__proxy'
                               ],
                 'module' => 'MP3::Tag',
                 'collect_pod' => undef,
                 'versions' => {
                                 'MP3::Tag::__hasparent' => bless( {
                                                                     'version' => [
                                                                                    1,
                                                                                    160
                                                                                  ],
                                                                     'original' => '1.16'
                                                                   }, 'version' )
                               }
               }, 'Module::Metadata' );

The module defines package MP3::Tag first, but then package MP3::Tag::__hasparent; inside a block, and after the block, declare the $VERSION without declaring the package MP3::Tag. It's legal but is confusing some of the toolchain tools like this, so the best way to fix this would be to patch it in the upstream.

https://metacpan.org/dist/MP3-Tag/source/lib/MP3/Tag.pm

The version declaration can simply be moved up to the top of the file, right after package MP3::Tag.