A good reason not to version submodules.

Probably you do not agree with my point of view, but I think that adding version numbers to sub-modules is, most of the times, counter-productive.

Explaining what I mean by adding version numbers to sub-modules. If I have a module, named Foo::Bar that ships with Foo::Bar::Helper, probably I don't want to add a version to Helper module.

Or if you do, be sure to keep or increment it on every release you do.

Why this matters? Well, it matters to the people who use cpan and the r command to check for outdated modules:

CHI::Driver::Role::HasSubcaches     undef      0.45  JSWARTZ/CHI-0.45.tar.gz
CHI::Serializer::JSON         undef      0.43  JSWARTZ/CHI-0.43.tar.gz
CHI::Test::Class              undef      0.39  JSWARTZ/CHI-0.39.tar.gz
Mason::DynamicFilter           undef      2.06  JSWARTZ/Mason-2.06.tar.gz
Mason::Plugin::Defer::Filters     undef      2.01  JSWARTZ/Mason-2.01.tar.gz

Basically, these modules had a version number on old releases. With new releases they were removed. Now, cpan thinks they are outdated.

Not sure what would be the solution now, but maybe to add a version number again (and keep it, like "version 100", just for the sake of keeping this from happening), or delete old modules from CPAN (as in, move them to BackPAN, so that these submodules are not indexed).


Use Dist::Zilla, stop worrying (about the sub-module versions), and learn to love the bomb. ;-)

Kick them in the head and tell them to use dzil?? May I help in the kicking? :-)

The real advice here is to never switch a versioning style. Once you choose something, just stick with it. If you want to use a different version method, use it for new modules.

In some of my modules I used the following technique : import the main distribution module, and copy the distrib. number.

use My::Main::Module; our $VERSION=$My::Main::Module::VERSION;

Distributions can be split or combined over their history. Most recently this happened to LWP. Because of this, you don’t want to depend on distributions, you want to depend on the specific modules you use and you want to depend on every single one of them, even if several of them are in the same distribution.

F.ex., if you use HTML::Form and use LWP::UserAgent, then you should have listed both of them as dependencies, even though they both used to be in the libwww-perl distribution. If you did that, then the CPAN client would figure out that you need two distributions for these modules since LWP has been split up – your distribution continues to install correctly without you having to update it.

But this means you must depend on every single separate module. If that is so, then to make dependency resolution work correctly, every single one of these modules needs to have an explicit version number. So it follows that every single module must have a version number or else the CPAN will not work right in all cases.

I'm the author of both modules in question, thanks for the kicking. :)

Initially I autogenerated Versions for all submodules via dzil. I didn't like all the diff-churn, so I thought I'd change it to only generate Version numvers for modules with POD (i.e. the modules with a public interface). However it was obviously unwise to switch this for existing distributions. I will shortly push new releases of these distributions with all the submodule Versions restored.

I'm still on the fence regarding submodule Versions, since I don't like all the diff-churn, but people In The Know seem to feel it's the best way to go. Some discussion here:


Leave a comment

About Alberto Simões

user-pic I blog about Perl. D'uh!