简体   繁体   中英

Installing a patch for a dependent module: cpanm still tries to install broken module after I have installed patched module manually

I am trying to install Net::SSH::Perl using cpanm (from perlbrew and perl version 5.30). The installation fails with:

$ cpanm Net::SSH::Perl
--> Working on Net::SSH::Perl
Fetching http://www.cpan.org/authors/id/S/SC/SCHWIGON/Net-SSH-Perl-2.14.tar.gz ... OK
Configuring Net-SSH-Perl-2.14 ... OK
==> Found dependencies: Crypt::Curve25519
--> Working on Crypt::Curve25519
Fetching http://www.cpan.org/authors/id/A/AJ/AJGB/Crypt-Curve25519-0.06.tar.gz ... OK
Configuring Crypt-Curve25519-0.06 ... OK
Building and testing Crypt-Curve25519-0.06 ... FAIL
! Installing Crypt::Curve25519 failed. See /home/hakon/.cpanm/work/1587758019.381709/build.log for details. Retry with --force to force install it.
! Installing the dependencies failed: Missing version info for module 'Crypt::Curve25519'
! Bailing out the installation for Net-SSH-Perl-2.14.

The problem with installing Crypt::Curve25519 is described in this issue. I downloaded the problematic module Crypt::Curve25519 and patched it:

git clone git@github.com:ajgb/crypt-curve25519.git
wget https://www.cpan.org/authors/id/S/SR/SREZIC/patches/Crypt-Curve25519-0.06-PR10-ANOTHERLINK.patch
cd crypt-curve25519
git apply ../Crypt-Curve25519-0.06-PR10-ANOTHERLINK.patch
perl Makefile.PL
make  # No errors now
make test
make install

However, when I try again to install Crypt::Curve25519 it still tries to install the broken module from CPAN:

$ cpanm Net::SSH::Perl
--> Working on Net::SSH::Perl
Fetching http://www.cpan.org/authors/id/S/SC/SCHWIGON/Net-SSH-Perl-2.14.tar.gz ... OK
Configuring Net-SSH-Perl-2.14 ... OK
==> Found dependencies: Crypt::Curve25519
--> Working on Crypt::Curve25519
Fetching http://www.cpan.org/authors/id/A/AJ/AJGB/Crypt-Curve25519-0.06.tar.gz ... OK
Configuring Crypt-Curve25519-0.06 ... OK
Building and testing Crypt-Curve25519-0.06 ... FAIL
! Installing Crypt::Curve25519 failed. See /home/hakon/.cpanm/work/1587758833.382749/build.log for details. Retry with --force to force install it.
! Installing the dependencies failed: Missing version info for module 'Crypt::Curve25519'
! Bailing out the installation for Net-SSH-Perl-2.14.

How can I make cpanm use the installed patch instead (ie skip installation of Crypt::Curve25519 since it is already installed)?

There's a few things to check:

  • cpanm knows where to find your patched version.
  • The patched version has a version that's higher than the one on CPAN. The module idea in CPAN assumes that you always want the latest, so ensure that yours is.
  • You don't want to install a patched module at the standard location because you don't want a cpan client to overwrite it.

Some other things that can work:

  • Force install the module and ignore the failures (cpanm has a --notest feature). The CPAN version is still installed, but that doesn't matter.
  • Have your patched version in a separate directory that's at the front of @INC so your program finds it first. This effectively hides the CPAN version.

The problem seems to be missing VERSION information in the module. By adding a line

our $VERSION = 0.06; 

to the top of the file lib/Crypt/Curve25519.pm and then reinstall, and then installing cpanm Net::SSH::Perl worked fine (it accepted the patched installation and did not try to download the broken version).

Here is the patch I used to lib/Crypt/Curve25519.pm :

diff --git a/lib/Crypt/Curve25519.pm b/lib/Crypt/Curve25519.pm
index 686b706..d9c2b3d 100644
--- a/lib/Crypt/Curve25519.pm
+++ b/lib/Crypt/Curve25519.pm
@@ -1,4 +1,5 @@
 package Crypt::Curve25519;
+our $VERSION = 0.06;
 #ABSTRACT: Generate shared secret using elliptic-curve Diffie-Hellman function

 use strict;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM