由於 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對於答案:

相關內容