choroba has asked for the wisdom of the Perl Monks concerning the following question:

I had to upgrade my OS, as opensuse Leap 42.2 reached the end of its support cycle.

Before upgrading, I ran

cpan -a

to create the "autobundle" of all the installed modules.

After upgrading, though, I realized the autobundle includes all the non-core modules, i.e. also the ones installed by the system vendor (zypper install perl-*). So, I iterated over the list of modules, tried to run perl -M$module -e1 for each of them, and only installed those that failed.

On one of the machines, Dancer failed to install with the following test failures:

t/04_static_file/01_mime_types.t .................... 1/10 # Failed test 'a mime_type is found with MIME::Types' # at t/04_static_file/01_mime_types.t line 16. # got: 'application/vnd.easykaraoke.cdgdownload' # expected: 'application/zip' # Looks like you failed 1 test of 10. t/04_static_file/01_mime_types.t .................... Dubious, test re +turned 1 (wstat 256, 0x100) Failed 1/10 subtests t/04_static_file/02_dir_traversal.t ................. ok t/05_views/002_view_rendering.t ..................... ok t/05_views/03_layout.t .............................. ok t/06_helpers/000_create_fake_env.t .................. ok t/06_helpers/01_send_file.t ......................... 1/25 # Failed test 'mime_type can be forced' # at t/06_helpers/01_send_file.t line 83. # got: 'image/vnd.mozilla.apng' # expected: 'image/png' # Looks like you failed 1 test of 25. t/06_helpers/01_send_file.t ......................... Dubious, test re +turned 1 (wstat 256, 0x100) Failed 1/25 subtests t/06_helpers/02_http_status.t ....................... ok t/06_helpers/03_content_type.t ...................... 1/6 # Failed test 'headers include expected data for GET /png' # at t/06_helpers/03_content_type.t line 36. # Looks like you failed 1 test of 6.

And indeed,

perl -MMIME::Types -wE 'say MIME::Types->new->mimeTypeOf("zip")'

returns application/vnd.easykaraoke.cdgdownload on that machine, while on others, it returns the expected application/zip. Any idea why that happens and how to fix it?

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re: Unexpected behaviour of MIME::Types
by Perlbotics (Archbishop) on Jan 28, 2018 at 15:39 UTC

    Could be a corrupted types.db file?

    Some things, you could check:

    • type perl # correct perl in use?
    • echo $PERL_MIME_TYPE_DB # is it set? (should not // set for testing)
    • perldoc -l MIME::Types # something like $DIR/Types.pod.

    There, inspect file $DIR/types.db. diff with versions of that file which work/work-not. Watch for line-endings, etc. Details of parsing can be found in MIME::Types::_read_db().

      Yes, there were some extra lines in types.db. Reinstall of MIME::Types after cleaning .cpan/build helped.

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re: Unexpected behaviour of MIME::Types
by karlgoethebier (Abbot) on Jan 30, 2018 at 14:18 UTC
    "...upgrade my OS...reached the end of its support cycle."

    Might be probably yet another reason to go for perlbrew - regardless of what your basic theme is ;-)

    Best regards, Karl (AKA Dr Wisenheimer)

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help