A script that I've been running fairly regularly for the last three to four years unexpectedly died (Compilation failed) today. I was unable to find a match for the error via Super Search. I did find information in various other locations so I thought I'd gather them together here to save the next person some effort.

I've found a (somewhat dodgy) work-around which fixes my immediate problem (described below). So, while I'm not actually asking for a solution, I'd be happy to hear about a better one.

I'm running Perl v5.18.1 on darwin-thread-multi-2level.

The error had two formats (from the same line of code). Initially, I got:

Invalid version format (version required) at .../Module/Runtime.pm lin +e 386.

After upgrading several modules, I got this:

Invalid version format (non-numeric data) at .../Module/Runtime.pm lin +e 386.

I found Ovid had written about this in blogs.perl.org: Moose Dying With "Invalid version format (version required)". There's a fair amount of discussion following Ovid's post.

A bug report has been raised for this: Bug #92989 for Module-Runtime: bad if statement causes use_module() and use_package_optimistically() to fail

Here's the Changes file describing the changes in Module::Runtime v0.014 that caused this issue.

My initial attempts at a solution involved upgrading whatever modules I could find that seemed likely to be involved. One of the issues raised in Ovid's blog and the bug report was the fact that the problematic modules were not reported. I don't have a list of what I ugraded and it was a fairly diverse lot (some examples: MooseX::NonMoose, MooseX::ClassAttribute, Exception::Class::Base, version, et al). At some point, the error message changed from "version required" to "non-numeric data", as stated above, but didn't get me any further.

I next tried rolling back to Module::Runtime v0.013. However, my version of Moose (2.1205) wanted Module::Runtime v0.014, so I reinstalled that.

Finally, [after making a copy] I manually edited .../Module/Runtime.pm, changing line 386, in use_package_optimistically(), from:

$name->VERSION($version) if @_ >= 2;

to

$name->VERSION($version) if @_ >= 2 && defined $version;

My old script was now running again!

[For anyone else choosing this path, there's a sub use_module($;$) {...} starting on line 346 which may need the same change. I didn't need to change this so, wanting to make the least manual changes, I left it alone.]

-- Ken


In reply to Module::Runtime - Invalid version format by kcott

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.