No se pudo instalar Ruby 2.7.7 en Ubuntu 20.04 debido a una falla de OpenSSL 1.1.1t

No se pudo instalar Ruby 2.7.7 en Ubuntu 20.04 debido a una falla de OpenSSL 1.1.1t
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

Este error... "No se encontró ninguna versión de openssl del sistema, asegúrese de que los encabezados de openssl estén instalados"... sugiere que necesito instalar manualmente OpenSSL 1.1.1t con encabezados, pero no estoy seguro de cómo hacerlo.

Respuesta1

  $ 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

Este comando instala los encabezados faltantes que provocan que falle la compilación.

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

Ahora la instalación debería funcionar...

  $ rbenv install 2.7.7
  $ rbenv global 2.7.7

Felicitaciones awww.techiediaries.compara la respuesta:

información relacionada