4

I have the need for a lightweight object system in a perl5 script. After reading the documentation for Mouse.pm, Moo.pm and Mo.pm, I was tossing up between Moo and Mo. The deciding factor in the end was that the Mo module has no dependencies (see right-hand side of page - "DEPENDENCIES" is grey out).

So, I go ahead with what I thought would be a simple install:

User@Ubuntu-iMac:~$ perl -MCPAN -e shell
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v2.05)
Enter 'h' for help.

cpan[1]> Terminal does not support GetHistory.
Lockfile removed.
User@Ubuntu-iMac:~$ sudo perl -MCPAN -e shell
[sudo] password for User: 
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v2.05)
Enter 'h' for help.

cpan[1]> install Mo
Reading '/home/User/.cpan/Metadata'
  Database was generated on Tue, 23 Feb 2016 02:17:02 GMT
Running install for module 'Mo'
Fetching with LWP:
http://www.cpan.org/authors/id/I/IN/INGY/Mo-0.39.tar.gz
Checksum for /home/User/.cpan/sources/authors/id/I/IN/INGY/Mo-0.39.tar.gz ok
Scanning cache /home/User/.cpan/build for sizes
............................................................................DONE
Configuring I/IN/INGY/Mo-0.39.tar.gz with Makefile.PL
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Mo
Writing MYMETA.yml and MYMETA.json
  INGY/Mo-0.39.tar.gz
  /usr/bin/perl Makefile.PL INSTALLDIRS=site -- OK
Running make for I/IN/INGY/Mo-0.39.tar.gz
---- Unsatisfied dependencies detected during ----
----            INGY/Mo-0.39.tar.gz           ----
    Moose [requires,optional]
    IO::All [requires,optional]
    Mouse [requires,optional]

 ... many lines of installation of dozens of modules deleted ...

So my question is - why did it think it needed Mouse, IO::All and, most painfull of all, Moose? Note I can see it says [requires,optional] - but I thought those two terms were contradictory.

Marty
  • 2,788
  • 11
  • 17
  • 3
    The Mo distribution includes two modules, Mo::Moose and Mo::Mouse, that use Moose and Mouse under the hood. The tests for these modules require that Moose and Mouse are installed. – ThisSuitIsBlackNot Feb 24 '16 at 01:12
  • 1
    build_requires / requires / commandline indicate where it found the dependency. "requires" really means "dependency" here. "Optional" indicates they are optional dependencies (as you can see [here](http://cpansearch.perl.org/src/INGY/Mo-0.39/META.json)). You have configured `cpan` to not ask you whether you want dependencies to be installed, so it installed them without asking. – ikegami Feb 24 '16 at 03:18
  • 1
    `Mo` ... *sigh* `&{$M.$_.::e}($P,\%e,\%o,\@_)for@_;return if$e{M};%e=(extends,sub{eval"no $_[0]()";@{$P.ISA}=$_[0]},has,sub{my$n=shift;my$m=sub{$#_?$_[0]{$n}=$_[1]:$_[0]{$n}} ...` makes me sad. – Sinan Ünür Feb 24 '16 at 04:51
  • @Sinan it's beautiful, isn't it? :) – simbabque Feb 24 '16 at 09:02
  • Thank you for the explanation of the dependencies as listed by CPAN.pm as it did the install. I guess it raises the question as to why the DEPENDENCIES at metacpan.org can be - let's say - misleading. – Marty Feb 24 '16 at 09:06
  • It's not misleading, at least not in this case. Had you not told `cpan` to install Mouse and Moose, Mo would still have worked fine. – ikegami Feb 24 '16 at 11:59
  • @Marty have a look at the META.json and you'll see that the only runtime requirement listed is perl itself https://metacpan.org/source/INGY/Mo-0.39/META.json#L47 Moose is under "recommends". – oalders Feb 25 '16 at 15:42

0 Answers0