miyagawa / cpanminus

cpanminus - get, unpack, build and install modules from CPAN
http://cpanmin.us
755 stars 213 forks source link

If cpanfile is used, check first for minimum perl version #524

Open y opened 7 years ago

y commented 7 years ago

If you specify a minimum perl version in your cpanfile, cpanm (and Carton) will still try to install all other modules, before finally showing an error about the perl version mismatch. I think it would make more sense, and be more user-friendly, to first check if a perl version is specified, and if so, bail if the version doesn't match.

y commented 3 years ago

Finally looked in the source and I see it issues a message and collects the failure but then never actually makes use of that failure. Not sure how to work with the fatpack stuff so couldn't properly test, but the fix could be as simple as this:

diff --git a/Menlo-Legacy/lib/Menlo/CLI/Compat.pm b/Menlo-Legacy/lib/Menlo/CLI/Compat.pm
index d9bf8af..be256bd 100644
--- a/Menlo-Legacy/lib/Menlo/CLI/Compat.pm
+++ b/Menlo-Legacy/lib/Menlo/CLI/Compat.pm
@@ -1877,6 +1877,7 @@ sub install_deps {
             if ($dep->is_requirement && !$self->check_perl_version($dep->version)) {
                 $self->diag("Needs perl @{[$dep->version]}, you have $]\n");
                 push @fail, 'perl';
+                return 0, \@fail;
             }
         } elsif ($self->should_install($dep->module, $dep->version)) {
             push @install, $dep;