sergot / openssl

OpenSSL bindings for Perl 6
MIT License
14 stars 31 forks source link

Installing version 0.1.25 fails with 'Unable to read key ' most of the time (Debian 10|Buster) #87

Closed usev6 closed 3 years ago

usev6 commented 3 years ago

As reported in https://github.com/sergot/openssl/issues/82#issuecomment-869027298 installing this module in version 0.1.25 fails most of the time. I'm opening a new issue for this problem, since it looks like a different failure from the original problem reported in https://github.com/sergot/openssl/issues/82.

$ git clone https://github.com/sergot/openssl.git
$ cd openssl
$ zef install .
===> Searching for missing dependencies: PathTools, JSON::Fast
===> Updating fez mirror: http://360.zef.pm/
===> Updating cpan mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/cpan1.json
===> Updating p6c mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json
===> Updated p6c mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json
===> Updated fez mirror: http://360.zef.pm/
===> Updated cpan mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/cpan1.json
===> Building: OpenSSL:ver<0.1.25>
===> Building [OK] for OpenSSL:ver<0.1.25>
===> Testing: PathTools:ver<0.1.1>:auth<github:ugexe>
===> Testing [OK] for PathTools:ver<0.1.1>:auth<github:ugexe>
===> Testing: JSON::Fast:ver<0.16>
===> Testing [OK] for JSON::Fast:ver<0.16>
===> Testing: OpenSSL:ver<0.1.25>
[OpenSSL] # NETWORK_TESTING was not set
[OpenSSL] Unable to read key
[OpenSSL]   in method new at /home/christian/openssl/lib/OpenSSL/RSATools.pm6 (OpenSSL::RSATools) line 23
[OpenSSL]   in block <unit> at t/03-rsa.t line 10
[OpenSSL] # NETWORK_TESTING was not set
===> Testing [FAIL]: OpenSSL:ver<0.1.25>
Aborting due to test failure: OpenSSL:ver<0.1.25> (use --force-test to override)

If one retries the install command several times it eventually succeeds.

I only tested on Debian 10 (buster), but I wouldn't be surprised if the error happens on other systems, too.

$  raku --version
Welcome to Rakudo(tm) v2021.05.
Implementing the Raku(tm) programming language v6.d.
Built on MoarVM version 2021.05.
$ cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

The problem happens since https://github.com/sergot/openssl/commit/dcf88a825c. (I tried multiple times with that commit reverted and didn't see a single failure.)

Interestingly, the problem also happens (maybe less often) on the mentioned commit with the following change:

diff --git a/Build.pm6 b/Build.pm6
index 3e8ca16..91785f2 100644
--- a/Build.pm6
+++ b/Build.pm6
@@ -1,4 +1,3 @@
-use PathTools;
 use JSON::Fast;

 unit class Build;
@@ -26,12 +25,5 @@ method build($cwd --> Bool) {
     my $json = to-json(%libraries, :pretty, :sorted-keys);
     "resources/libraries.json".IO.spurt: $json;

-    # DO NOT COPY THIS SOLUTION
-    # Delete precomp files when building in case the openssl libs have since been updated
-    # (ideally this type of stale precomp would get picked up by raku)
-    # see: https://github.com/sergot/openssl/issues/82#issuecomment-864523511
-    try rm($cwd.IO.child('.precomp').absolute, :r, :f, :d);
-    try rm($cwd.IO.child('lib/.precomp').absolute, :r, :f, :d);
-
     return True;
 }

So, the problem is not caused by the deletion of the .precomp directories (which were introduced as a workaround for https://github.com/sergot/openssl/issues/82 with https://github.com/sergot/openssl/commit/72ce2495b6). (In my example there was no .precomp directory in the first place.)

Instead it feels like there is some kind of problem with (the interaction of) the precompilation of the dependencies. If I -- additionally to the above diff -- remove PathTools from the build-depends in META6.json the error does not happen.

Alternatively I could leave the code that uses PathTools alive and revert the commit that introduced the dependency on JSON::Fast (https://github.com/sergot/openssl/commit/dcf88a825c) -- and again the error does not happen. From my perspective that could be a valid workaround in the current situation, since it leaves the first workaround for https://github.com/sergot/openssl/issues/82 in place.

usev6 commented 3 years ago

I've run the following commands a couple of times and everything worked as expected (no error at all). So I think, we are good again.

$ rm -rf ~/.zef/ ~/.raku/
$ /opt/rakudo-pkg/bin/install-zef
$ zef install OpenSSL
$ raku -e 'use OpenSSL; say "alive"'

I'm closing this issue.