asdf-ruby icon indicating copy to clipboard operation
asdf-ruby copied to clipboard

Fails building Ruby 2.6.9 on Ubuntu 22.04

Open kucho opened this issue 3 years ago • 8 comments

Description

Building MRI 2.6.9 fails on Ubuntu 22.04

❯ asdf install ruby 2.6.9 
Downloading ruby-2.6.9.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.9.tar.bz2
Installing ruby-2.6.9...

BUILD FAILED (Ubuntu 22.04 using ruby-build 20220324)

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

Last 10 log lines:
linking shared-object psych.so
make[2]: Leaving directory '/tmp/ruby-build.20220325231824.25010.hCPBpy/ruby-2.6.9/ext/psych'
linking shared-object objspace.so
make[2]: Leaving directory '/tmp/ruby-build.20220325231824.25010.hCPBpy/ruby-2.6.9/ext/objspace'
linking shared-object bigdecimal.so
make[2]: Leaving directory '/tmp/ruby-build.20220325231824.25010.hCPBpy/ruby-2.6.9/ext/bigdecimal'
linking shared-object nkf.so
make[2]: Leaving directory '/tmp/ruby-build.20220325231824.25010.hCPBpy/ruby-2.6.9/ext/nkf'
make[1]: Leaving directory '/tmp/ruby-build.20220325231824.25010.hCPBpy/ruby-2.6.9'
make: *** [uncommon.mk:286: build-ext] Error 2

Complete log: http://ix.io/3Tuq

Environment

❯ asdf info
OS:
Linux r0n1n 5.15.0-23-generic #23-Ubuntu SMP Fri Mar 11 14:54:05 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

SHELL:
zsh 5.8.1 (x86_64-ubuntu-linux-gnu)

ASDF VERSION:
v0.9.0-7493f40

ASDF ENVIRONMENT VARIABLES:
ASDF_DIR=/home/kucho/Git/asdf

ASDF INSTALLED PLUGINS:
direnv                       https://github.com/asdf-community/asdf-direnv.git master 3e7578b
nodejs                       https://github.com/asdf-vm/asdf-nodejs.git master f9957f3
ruby                         https://github.com/asdf-vm/asdf-ruby.git master 811c824

❯ openssl version   
OpenSSL 3.0.1 14 Dec 2021 (Library: OpenSSL 3.0.1 14 Dec 2021)

~ 
❯ gcc --version      
gcc (Ubuntu 11.2.0-18ubuntu1) 11.2.0

~ 
❯ make --version
GNU Make 4.3

kucho avatar Mar 26 '22 04:03 kucho

I managed to install ruby 2.6.9 and 3.1.1 after compiling openssl-1.1.1n following this guide and running:

RUBY_CONFIGURE_OPTS="--with-openssl-dir=/compiled/openssl-1.1.1n/path" asdf install ruby x.x.x

kucho avatar Mar 27 '22 03:03 kucho

Thanks @kucho ! This worked for me as well. It looks like Ubuntu 22.04 ships by default with OpenSSL 3 and I couldn't find any backport of 1.1.x.

I only had to download, build and install 1.1.1. You can safely ignore step 12+ from the linked guide. I'm pretty sure ruby-build only needs the libs and the remaining steps sets your default OpenSSL to 1.1.1.

steveclarke avatar Apr 24 '22 12:04 steveclarke

Thanks @kucho ! This worked for me as well. It looks like Ubuntu 22.04 ships by default with OpenSSL 3 and I couldn't find any backport of 1.1.x.

I only had to download, build and install 1.1.1. You can safely ignore step 12+ from the linked guide. I'm pretty sure ruby-build only needs the libs and the remaining steps sets your default OpenSSL to 1.1.1.

Unfortunally not worked for me, I'm on Fedora 36.

Stacktrace below:

─ RUBY_CONFIGURE_OPTS="--with-openssl-dir=/compiled/openssl-1.1.1n/path" asdf install ruby 3.0.2
Downloading ruby-3.0.2.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.2.tar.gz
Installing ruby-3.0.2...

BUILD FAILED (Fedora Linux 36 using ruby-build 20220426)

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

Last 10 log lines:
cc1: note: unrecognized command-line option ‘-Wno-constant-logical-operand’ may have been intended to silence earlier diagnostics
make[2]: Leaving directory '/tmp/ruby-build.20220517235744.74076.LJ6VeV/ruby-3.0.2/ext/openssl'
make[1]: *** [exts.mk:260: ext/openssl/all] Error 2
make[1]: *** Waiting for unfinished jobs....
linking shared-object socket.so
make[2]: Leaving directory '/tmp/ruby-build.20220517235744.74076.LJ6VeV/ruby-3.0.2/ext/socket'
linking shared-object ripper.so
make[2]: Leaving directory '/tmp/ruby-build.20220517235744.74076.LJ6VeV/ruby-3.0.2/ext/ripper'
make[1]: Leaving directory '/tmp/ruby-build.20220517235744.74076.LJ6VeV/ruby-3.0.2'
make: *** [uncommon.mk:300: build-ext] Error 2

Environment:

-- gcc --version    
gcc (GCC) 12.1.1 20220507 (Red Hat 12.1.1-1)
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

-- asdf info              
OS:
Linux fedora 5.17.7-300.fc36.x86_64 #1 SMP PREEMPT Thu May 12 14:56:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

SHELL:
zsh 5.8.1 (x86_64-redhat-linux-gnu)

ASDF VERSION:
v0.10.0-77fd510

ASDF ENVIRONMENT VARIABLES:
ASDF_DIR=/home/jacom/.asdf

ASDF INSTALLED PLUGINS:
nodejs                       https://github.com/asdf-vm/asdf-nodejs.git master b2d06a7
python                       https://github.com/danhper/asdf-python.git master 57ef777
ruby                         https://github.com/asdf-vm/asdf-ruby.git master 5180586
rust                         https://github.com/code-lever/asdf-rust.git master 0c88f99


-- make --version 
GNU Make 4.3
Built for x86_64-redhat-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

jacodoisdois avatar May 18 '22 03:05 jacodoisdois

@jacomaga you should replace dir=/compiled/openssl-1.1.1n/path with the actual path of the compiled openssl folder, e.g dir=~/.openssl/openssl-1.1.1n.

Likewise, this version does not have any certificates, so you will need to symlink the certs from your system to it:

# Remove existing folder from compiled openssl
rm -rf ~/.openssl/openssl-1.1.1n/certs

# Ubuntu
ln -s /etc/ssl/certs ~/.openssl/openssl-1.1.1n/certs

# Fedora
ln -s /etc/pki/tls/certs ~/.openssl/openssl-1.1.1n/certs

I am not sure the system certs path on Fedora is right. Can you try it?

kucho avatar May 18 '22 03:05 kucho

Author I am not sure the system certs path on Fedora is right. Can you try it?

🤦

Damn, I just fixed the path and works.

Thank you, mate.

And about the certification the path is correct.

jacodoisdois avatar May 18 '22 05:05 jacodoisdois

Another way to resolve this problem is changing utils.sh to https://github.com/znz/ruby-build.git and use the command to install ASDF_RUBY_BUILD_VERSION=install-openssl_1-when-openssl_is_3 asdf install ruby <ruby-version>

More details you can check here

guilhermecomum avatar Jul 05 '22 16:07 guilhermecomum

@guilhermecomum thanks for the link!! Your suggested command did not work for me but I found the solution in the linked PR:

brew install [email protected]
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix [email protected])"

i7an avatar Jul 28 '22 17:07 i7an

Just to add to @i7an 's answer, I had to removing the latest openssl@3, then uninstall and install [email protected] while ignoring the dependency warnings.

Then I uninstalled the specific ruby version that was having the certificate problem, then I added the exported RUBY_CONFIGURE_OPTS:


export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix [email protected])"
asdf install ruby 2.6.1
asdf reshim ruby

Then finally the cert issue was solved for me.

ctrlaltdylan avatar Aug 15 '22 16:08 ctrlaltdylan

@kucho If you don't mind, would you be ok closing this issue? It sounds like it's cleaned up.

SeanSith avatar Mar 30 '23 20:03 SeanSith

Just in case someone finds this when searching for a solution:

I'm on PopOS, which is basically Ubuntu. What worked for me was

  1. install openssl 1.1.1n following these instructions: https://help.dreamhost.com/hc/en-us/articles/360001435926-Installing-OpenSSL-locally-under-your-username (excluding steps 12+)
  2. to install ruby run RUBY_CONFIGURE_OPTS="--with-openssl-dir=~/openssl --with-openssl-lib=/" asdf install ruby latest.

I needed to specify --with-openssl-lib=/, because without that option it kept looking for /lib in /openssl/lib...

Ninigi avatar Mar 16 '24 00:03 Ninigi