由于 OpenSSL 1.1.1t 失败,无法在 Ubuntu 20.04 上安装 Ruby 2.7.7

由于 OpenSSL 1.1.1t 失败,无法在 Ubuntu 20.04 上安装 Ruby 2.7.7
ubuntu$ rbenv install 2.7.7
To follow progress, use 'tail -f /tmp/ruby-build.20230330011330.8040.log' or pass --verbose
No system openssl version was found, ensure openssl headers are installed (https://github.com/rbenv/ruby-build/wiki#suggested-build-environment)
Downloading openssl-1.1.1t.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/8dee9b24bdb1dcbf0c3d1e9b02fb8f6bf22165e807f45adeb7c9677536859d3b
Installing openssl-1.1.1t...

BUILD FAILED (Ubuntu 22.04 using ruby-build 20230309-1-gf3c1ccc)

Inspect or clean up the working tree at /tmp/ruby-build.20230330011330.8040.QBCH0Y
Results logged to /tmp/ruby-build.20230330011330.8040.log

Last 10 log lines:
gcc  -I. -Iinclude -fPIC -pthread -Wa,--noexecstack -Wall -O3 -DOPENSSL_USE_NODELETE -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DVPAES_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/home/ubuntu/.rbenv/versions/2.7.7/openssl/ssl\"" -DENGINESDIR="\"/home/ubuntu/.rbenv/versions/2.7.7/openssl/lib/engines-1.1\"" -DZLIB -DZLIB_SHARED -DNDEBUG -I/home/ubuntu/.rbenv/versions/2.7.7/include  -MMD -MF crypto/comp/c_zlib.d.tmp -MT crypto/comp/c_zlib.o -c -o crypto/comp/c_zlib.o crypto/comp/c_zlib.c
gcc  -I. -Iinclude -fPIC -pthread -Wa,--noexecstack -Wall -O3 -DOPENSSL_USE_NODELETE -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DVPAES_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/home/ubuntu/.rbenv/versions/2.7.7/openssl/ssl\"" -DENGINESDIR="\"/home/ubuntu/.rbenv/versions/2.7.7/openssl/lib/engines-1.1\"" -DZLIB -DZLIB_SHARED -DNDEBUG -I/home/ubuntu/.rbenv/versions/2.7.7/include  -MMD -MF crypto/comp/comp_err.d.tmp -MT crypto/comp/comp_err.o -c -o crypto/comp/comp_err.o crypto/comp/comp_err.c
crypto/comp/c_zlib.c:35:11: fatal error: zlib.h: No such file or directory
   35 | # include <zlib.h>
      |           ^~~~~~~~
compilation terminated.
make[1]: *** [Makefile:2185: crypto/comp/c_zlib.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/tmp/ruby-build.20230330011330.8040.QBCH0Y/openssl-1.1.1t'
make: *** [Makefile:174: all] Error 2

这个错误...“未找到系统 openssl 版本,请确保已安装 openssl 标头”...表明我需要手动安装带有标头的 OpenSSL 1.1.1t,但不确定如何执行此操作。

答案1

  $ git clone https://github.com/rbenv/rbenv.git ~/.rbenv

  $ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
  $ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
  $ . ~/.bashrc

  $ git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

此命令安装导致构建失败的缺少的标题。

  $ sudo apt-get install -y libreadline-dev zlib1g-dev

现在安装就可以正常工作了...

  $ rbenv install 2.7.7
  $ rbenv global 2.7.7

感谢www.techiediaries.com答案是:

相关内容