Skip to content

Commit

Permalink
Unload modules before rechecking version after installation
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed May 1, 2018
1 parent fd4248c commit 775fae9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions install-deps.pl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@

sub is_installed
{
my ( $mod, $want_ver ) = @_;
my ( $mod, $want_ver, %opts ) = @_;

( my $modfile = "$mod.pm" ) =~ s{::}{/}g;

if( $opts{unload_first} ) {
# unload the module in case we already loaded an older version
delete $INC{$modfile};
}

return 0 unless( eval { require $modfile; 1 } );

defined $want_ver or return 1;
Expand All @@ -40,7 +46,7 @@ sub requires
# cpan returns zero even if installation fails, so we double-check
# that the module is installed after running it.
system( $^X, "-MCPAN", "-e", qq(install "$mod") ) == 0 and
is_installed( $mod, $ver ) and
is_installed( $mod, $ver, unload_first => 1 ) and
return;

print STDERR "Failed to install $mod\n";
Expand Down

0 comments on commit 775fae9

Please sign in to comment.