【问题标题】:How can I install Net::SSLeay with perlbrew in macOS Catalina?如何在 macOS Catalina 中使用 perlbrew 安装 Net::SSLeay?
【发布时间】:2020-06-16 15:49:13
【问题描述】:

我正在尝试使用 perlbrew cpanm 在 Mac OSX Catalina 上安装 Net::SSLeay perl 包,但由于 openssl 相关问题而失败。

我尝试了以下所有解决方案均无济于事:

我已打开最新的 ssl 并将建议的导出添加到我的 .zshrc

我将这些添加到 .zshrc:

# Warning: Refusing to link macOS-provided software: openssl@1.1
# If you need to have openssl@1.1 first in your PATH run:
export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"

# For compilers to find openssl@1.1 you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

# For pkg-config to find openssl@1.1 you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

基本失败是:

cpanm (App::cpanminus) 1.7044 on perl 5.030001 built for darwin-2level
Work directory is /Users/<me>
/.cpanm/work/1583739797.88350
You have make /usr/bin/make
You have LWP 6.43
You have /usr/bin/tar: bsdtar 3.3.2 - libarchive 3.3.2 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.6
You have /usr/bin/unzip
Searching Net::SSLeay () on cpanmetadb ...
--> Working on Net::SSLeay
Fetching http://www.cpan.org/authors/id/C/CH/CHRISN/Net-SSLeay-1.88.tar.gz
-> OK
Unpacking Net-SSLeay-1.88.tar.gz
Entering Net-SSLeay-1.88
Checking configure dependencies from META.json
Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (7.34)
Configuring Net-SSLeay-1.88
Running Makefile.PL
Do you want to run external tests?
These tests *will* *fail* if you do not have network connectivity. [n] n
*** Found LibreSSL-2.8.3 installed in /usr
*** Be sure to use the same compiler and options to compile your OpenSSL, perl,
    and Net::SSLeay. Mixing and matching compilers is not supported.
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Net::SSLeay
Writing MYMETA.yml and MYMETA.json
-> OK
Checking dependencies from MYMETA.json ...
Checking if you have Test::More 0.60_01 ... Yes (1.302162)
Checking if you have ExtUtils::MakeMaker 0 ... Yes (7.34)
Checking if you have MIME::Base64 0 ... Yes (3.15)
Building and testing Net-SSLeay-1.88
cp lib/Net/SSLeay.pm blib/lib/Net/SSLeay.pm
AutoSplitting blib/lib/Net/SSLeay.pm (blib/lib/auto/Net/SSLeay)
blib/lib/Net/SSLeay.pm: some names are not unique when truncated to 8 characters:
 directory blib/lib/auto/Net/SSLeay:
  do_https3.al, do_https2.al, do_https4.al, do_https.al truncate to do_https
  do_httpx3.al, do_httpx2.al, do_httpx4.al truncate to do_httpx
  get_https.al, get_https3.al, get_https4.al, get_http.al, get_http3.al, get_http4.al, get_httpx.al, get_httpx3.al, get_httpx4.al truncate to get_http
  head_https.al, head_https3.al, head_https4.al, head_http.al, head_http3.al, head_http4.al, head_httpx.al, head_httpx3.al, head_httpx4.al truncate to head_htt
  post_https.al, post_https3.al, post_https4.al, post_http.al, post_http3.al, post_http4.al, post_httpx.al, post_httpx3.al, post_httpx4.al truncate to post_htt
  put_https.al, put_https3.al, put_https4.al, put_http.al, put_http3.al, put_http4.al, put_httpx.al, put_httpx3.al, put_httpx4.al truncate to put_http
  ssl_read_all.al, ssl_read_until.al, ssl_read_CRLF.al truncate to ssl_read
  ssl_write_all.al, ssl_write_CRLF.al truncate to ssl_writ
  tcp_read_all.al, tcp_read_until.al, tcp_read_CRLF.al truncate to tcp_read
  tcp_write_all.al, tcp_write_CRLF.al truncate to tcp_writ
cp lib/Net/SSLeay/Handle.pm blib/lib/Net/SSLeay/Handle.pm
cp lib/Net/SSLeay.pod blib/lib/Net/SSLeay.pod
Running Mkbootstrap for SSLeay ()
chmod 644 "SSLeay.bs"
"/Users/<me>
/perl5/perlbrew/perls/perl-5.30.1/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- SSLeay.bs blib/arch/auto/Net/SSLeay/SSLeay.bs 644
"/Users/<me>
/perl5/perlbrew/perls/perl-5.30.1/bin/perl" "/Users/<me>
/perl5/perlbrew/perls/perl-5.30.1/lib/5.30.1/ExtUtils/xsubpp"  -typemap '/Users/<me>
/perl5/perlbrew/perls/perl-5.30.1/lib/5.30.1/ExtUtils/typemap' -typemap '/Users/<me>
/.cpanm/work/1583739797.88350/Net-SSLeay-1.88/typemap'  SSLeay.xs > SSLeay.xsc
mv SSLeay.xsc SSLeay.c
cc -c   -fno-common -DPERL_DARWIN -mmacosx-version-min=10.15 -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -DPERL_USE_SAFE_PUTENV -O3   -DVERSION=\"1.88\" -DXS_VERSION=\"1.88\"  "-I/Users/<me>
/perl5/perlbrew/perls/perl-5.30.1/lib/5.30.1/darwin-2level/CORE"   SSLeay.c
SSLeay.xs:163:10: fatal error: 'openssl/err.h' file not found
#include <openssl/err.h>
         ^~~~~~~~~~~~~~~
1 error generated.
make: *** [SSLeay.o] Error 1
-> FAIL Installing Net::SSLeay failed. See /Users/<me>
/.cpanm/work/1583739797.88350/build.log for details. Retry with --force to force install it.

【问题讨论】:

  • 你关注OS X directions from Net::SSLeay了吗?您添加了哪些导出 .zshrc?尝试安装时的输出是什么?
  • @briandfoy 我添加了您要求的内容(针对基本案例)并将调查您的链接
  • @briandfoy 我安装了 openssl 但 cpanm 安装无法识别它。如果我使用链接中的说明,我可能会破坏 brew 安装并产生其他问题。因为我在 docker 映像中使用这些库,而这仅适用于 IDE 中的智能,所以我将放弃风险。
  • fatal error: 'openssl/err.h' file not found : 你能检查一下/usr/local/opt/openssl@1.1/include 中是否有文件openssl/err.h 吗?
  • @HåkonHægland 是的,我愿意(使用者)➜ ~ ls -la /usr/local/opt/openssl@1.1/include/openssl | grep -w err.h -rw-r--r-- 1 员工 11269 Sep 10 16:13 err.h (wielder) ➜ ~

标签: perl cassandra openssl macos-catalina


【解决方案1】:

经过一番折腾,我终于找到了这篇文章: OSX Catalina work around

我卸载了最新的 perlversion:

perlbrew uninstall perl-5.30.1

然后我运行了这个脚本

#!/usr/bin/env bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "$0 is running from: $DIR"

# make this file's location working dir
cd "$(dirname "$0")"


v='perl-5.30.1'

perl_versions=$(perlbrew list)

echo "perl_versions $perl_versions"

if [[ "$perl_versions" == *"$v"* ]]; then
    echo "$v is installed in perlbrew."
else
    echo "$v is not!!! installed in perlbrew.  installing ...."
    perlbrew install perl-5.30.1 --notest --force
fi


current_perl_version=$(which perl)

echo "current_perl_version: $current_perl_version"

if [[ "$current_perl_version" == *"$v"* ]]; then
    echo "$v is current version."
else
    echo "$v is not current version."
    perlbrew switch $v
fi


cpanm  install --force Test::Block
cpanm  install Try::Tiny
cpanm  install YAML
cpanm  install YAML::XS
cpanm  install JSON
cpanm  install JSON::MaybeXS
cpanm  install HTTP::Request
cpanm  install HTTP::Response
cpanm  install HTTP::Daemon

cpanm  install GD::Simple
cpanm  install GD::Graph
cpanm  install Data::HexDump::Range
cpanm  install Proc::Daemon
cpanm  install Test::Block
cpanm  install Text::Colorizer
cpanm  install Gzip::Faster

cpanm  install IO::Socket::INET6

#export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"
#export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
#export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

cpanm install DBI

#cpanm  install Net::SSLeay
OPENSSL_PREFIX=/usr/local/opt/openssl@1.1 cpanm --interactive --verbose --force Net::SSLeay


cpanm install --force Cassandra::Client

cpanm install DBD::Cassandra
#cpanm install https://cpan.metacpan.org/authors/id/T/TV/TVDW/Cassandra-Client-0.16.tar.gz

cpanm  install Proc::ProcessTable
cpanm  install Kafka::Connection

在安装 Net::SSLeay 期间,系统提示我手动确认依赖于网络连接的测试并回答 y。如果有人知道 perlbrew 中的自动批准,请发表评论,快速浏览 perlbrew -h 乍一看并没有提供关于自动批准选项的信息。

【讨论】:

  • 设置 OPENSSL_PREFIX 正是 Net::SSLeay OS X README 指令所说的。这是我在我的 bash 个人资料中设置的。
  • @briandfoy 我想知道它是否不会影响其他程序的路径
【解决方案2】:

我在 macOS Catalina 上试过这个(注意我的 shell 是 bash 而不是默认的 zsh):

brew install openssl
\curl -L https://install.perlbrew.pl | bash

安装perlbrew后,编辑~/.bash_profile

source ~/perl5/perlbrew/etc/bashrc
export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

然后保存,执行

$ source ~/.bash_profile
$ perlbrew install-cpanm
$ perlbrew install perl-5.30.1 --notest
$ perlbrew switch perl-5.30.1
$ cpanm Net::SSLeay
--> Working on Net::SSLeay
Fetching http://www.cpan.org/authors/id/C/CH/CHRISN/Net-SSLeay-1.88.tar.gz ... OK
Configuring Net-SSLeay-1.88 ... OK
Building and testing Net-SSLeay-1.88 ... OK
Successfully installed Net-SSLeay-1.88
1 distribution installed

所以我的猜测是这个问题与zsh 有关,因为我使用了bash 而你使用了zsh

【讨论】:

  • 我尝试将它移动到 bashrc,它出现在 shell 环境变量中,但失败了
  • 我正在从 perlbrew 中删除 perl 版本并重新开始安装,希望它能正常工作,我会背书
  • 重新安装 perl 没有帮助
猜你喜欢
  • 1970-01-01
  • 2020-02-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-02-10
  • 2014-03-10
  • 1970-01-01
  • 2018-11-27
相关资源
最近更新 更多