Skip to content

Instantly share code, notes, and snippets.

@skaji
Created August 8, 2019 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skaji/9f8d1def2a447ad6259d6ac6f8faa7df to your computer and use it in GitHub Desktop.
Save skaji/9f8d1def2a447ad6259d6ac6f8faa7df to your computer and use it in GitHub Desktop.

if we apply adjust how to check modules are installed or not, then

with perl 5.8.5

❯ perl -Ilib cpm.test install File::Spec
WARN You don't have Module::CoreList. The local-lib may result in incomplete self-contained directory.
DONE install Perl-OSType-1.010
DONE install Locale-Maketext-Simple-0.21
DONE install version-0.9924
FAIL install ExtUtils-CBuilder-0.280231
FAIL install ExtUtils-ParseXS-3.35
FAIL install IPC-Cmd-1.04
FAIL install Module-CoreList-5.20190720
FAIL install Module-Load-0.34
FAIL install Module-Load-Conditional-0.68
FAIL install Module-Metadata-1.000036
FAIL install Params-Check-0.38
FAIL install PathTools-3.75
FAIL install Test-Simple-1.302164
3 distributions installed.
See /Users/skaji/.perl-cpm/build.log for details.
@skaji
Copy link
Author

skaji commented Aug 8, 2019

commit b68cd14bc5d46fe8e2d7ee77df18e18d71a74105
Author: Shoichi Kaji <skaji@cpan.org>
Date:   Sun Jul 16 22:14:06 2017 +0900

    adjust how to check modules are installed or not

diff --git a/lib/App/cpm/Master.pm b/lib/App/cpm/Master.pm
index 92e040b..352f052 100644
--- a/lib/App/cpm/Master.pm
+++ b/lib/App/cpm/Master.pm
@@ -316,14 +316,15 @@ sub is_satisfied {
             next;
         }
         next if $self->{target_perl} and $self->is_core($package, $version_range);
-        next if $self->is_installed($package, $version_range);
-        my ($resolved) = grep { $_->providing($package, $version_range) } @distributions;
-        next if $resolved && $resolved->installed;

-        $is_satisfied = 0 if defined $is_satisfied;
-        if (!$resolved) {
+        my ($resolved) = grep { $_->providing($package, $version_range) } @distributions;
+        if ($resolved) {
+            next if $resolved->installed;
+        } else {
+            next if $self->is_installed($package, $version_range);
             push @need_resolve, $req;
         }
+        $is_satisfied = 0 if defined $is_satisfied;
     }
     return ($is_satisfied, @need_resolve);
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment