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

For reasons explained below, I released a CPAN module Spreadsheet::Edit containing two $VERSION assignments like this:
  $Spreadsheet::Edit::VERSION = 999.999; # intended to be over-ridden in released dist
  our $VERSION = 3.024; # VERSION from Dist::Zilla::Plugin::OurPkgVersion
My intention was for the second assignment to be effective, i.e. to set VERSION=3.024. I didn't realize that PAUSE and the tester system textually search for the first such assignment. I deleted the release via pause, but many test machines have it installed and think they have version 999.999 and therefore refuse to update the module when something requires a later actual version such as 3.029.

My question: Is it safe to bump the actual version to 1000.001 to fix this, or will a primary version with more than 3 digits break something?

--------------------

If you wonder why I did such a thing, here is why:

I maintain several CPAN modules and, in my personal sandbox I want to use the working trees of these modules by default (i.e. eat my own dog food); and so I put /path/to/src/Module-Foo/lib etc. as the first items in PERL5LIB. That way my development code will be used instead of whatever version might have been installed with cpanm in my local::lib area.

Fine. Until I needed to require a minimum version e.g. "use Spreadsheet::Edit 3.029;" which bombed because there is no $VERSION variable in the working tree code. $VERSION variables were inserted only when building a release tarball using Dist::Zilla. I use the OurPkgVersion plug-in which inserts "our $VERSION = ...;" before a "# VERSION" comment, which of course is still just a comment in my working tree.

So I inserted a hard-coded assignment setting VERSION to "infinity" before the # VERSION comment, so that my working tree code would satisfy any "use ... version" requirement. The result, in the released code, was the pair of assignments shown above.

Replies are listed 'Best First'.
Re: Is VERSION > 999 allowed?
by swl (Prior) on Jun 28, 2023 at 00:40 UTC
Re: Is VERSION > 999 allowed?
by hippo (Archbishop) on Jun 28, 2023 at 06:29 UTC
    many test machines have it installed

    That's interesting because I don't see it indexed either at CPAN or at BACKPAN. Are these your test machines? If so, just uninstall the troublesome module and re-install the correctly-versioned one.

    $VERSION variables were inserted only when building a release tarball using Dist::Zilla.

    Although I am no fan at all of Dist::Zilla, I still find it hard to believe that it won't/can't just overwrite an existing version with a newer one. Presumably there is a plugin which will do that.

    And to address the original question, yes, 4-digit version numbers are fine. Probably any version up to (2^31 - 1) will be OK.


    🦛

      Thanks for the replies. I'll bump the version to 1000.x and make the using modules require that.

      @hippo - the reason you can't find the affected versions on CPAN is that I deleted them (via pause). Anyway CPAN *indexed* the releases correctly, i.e. as 3.024 was indexed as 3.024. However once any version with the extra $VERSION declaration is installed on a cpan-testers machine, the test machinery (or maybe cpanm) thinks it has version 999.999 and so won't update it.

      For example, see http://www.cpantesters.org/cpan/report/b4581f16-132e-11ee-8887-54486e8775ea

      The test fails because "Spreadsheet::Edit::IO version 3.03 required--this is only version 3.022". This should not happen because version '3.030' is a dependency listed in META.yml and so that version (or later) should have been installed. The explanation becomes clear looking further down where it says:

      Prerequisite modules loaded:
      requires:
      
          Module                    Need     Have    
          ------------------------- -------- --------
          Algorithm::Diff           0        1.201   
          ...
          Spreadsheet::Edit         3.025    999.999 
          Spreadsheet::Edit::IO     3.030    999.999 <****
      
      The test machine installed v3.022 previously, but now it thinks it has v999.999.
        I find this strange, because I was pretty sure that the only way to check the installed version of a module was to load it and call ->VERSION. There isn't any database of package versions within a perl installation that I know of. Are you sure that when you load the published version 3.03 and call ->VERSION it returns '3.03'?

        Meanwhile, yes the CPAN tooling does manually parse out your version rather than evaling untrusted code. One thing I have done to solve similar problems (where I needed there to be a version for testing but was injecting the real version as dist build time) was put

        # VERSION $MYPACKAGE::VERSION ||= '999';
        So, let the real one come first, then apply one if it doesn't exist. Maybe just to be *really* sure tooling can't parse the bogus version, you could write it as a harder-to-parse expression, before 'use strict':
        package MYPACKAGE; # VERSION ${ __PACKAGE__ . '::VER' . 'SION' } ||= 2**10; use strict;

        Edit:

        Oh! HAH, I remember now, I stopped doing that because I contributed the 'overwrite' option, which allows you to write

        [OurPkgVersion] overwrite = 1
        package MYPACKAGE; our $VERSION= '999'; # VERSION
        and it just gets overwritten with the real version when released.

        Thanks for this extra info - I now understand that it was only the module versions which were incorrect but the dist version was correct. That explains why I couldn't find version 999.999 on CPAN or BackPAN.

        However once any version with the extra $VERSION declaration is installed on a cpan-testers machine, the test machinery (or maybe cpanm) thinks it has version 999.999 and so won't update it.

        That should only be temporary, I would have thought. See this recent discussion regarding common dependencies not being present on smoke testers' machines. They might not all work this same way, of course - I'm not running a smoke tester (yet) so can't comment further on that. Anyway, you've taken the plunge with the 4-digit major version now so this is all moot.


        🦛