Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 883097 - dev-lang/ruby-3.1.3 fails to compile: rubygems.rb:16:in require: cannot load such file compatibility (LoadError)
Summary: dev-lang/ruby-3.1.3 fails to compile: rubygems.rb:16:in require: cannot load ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Ruby Team
URL:
Whiteboard:
Keywords:
: 890036 904059 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-11-26 09:44 UTC by Agostino Sarubbo
Modified: 2023-04-10 07:36 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (build.log,598.36 KB, text/plain)
2022-11-26 09:44 UTC, Agostino Sarubbo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Agostino Sarubbo gentoo-dev 2022-11-26 09:44:00 UTC
https://blogs.gentoo.org/ago/2020/07/04/gentoo-tinderbox/

Issue: dev-lang/ruby-3.1.3 fails to compile (CLANG-STRICTER-SYSTEM).
Discovered on: amd64 (internal ref: clang-stricter_tinderbox)

NOTE:
(CLANG-STRICTER-SYSTEM) in the summary means that the bug was found on a machine that runs clang with stricter mode

This machine uses clang with CFLAGS/CXXFLAGS=-Werror=implicit-function-declaration -Werror=implicit-int -Werror=incompatible-function-pointer-types

See also:
https://archives.gentoo.org/gentoo-dev/message/dd9f2d3082b8b6f8dfbccb0639e6e240
https://wiki.gentoo.org/wiki/Modern_C_porting
Comment 1 Agostino Sarubbo gentoo-dev 2022-11-26 09:44:03 UTC
Created attachment 836837 [details]
build.log

build log and emerge --info
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-12-11 02:09:31 UTC
Had a few reports of this on IRC in #gentoo too.

```
/usr/bin/ruby --disable=gems -C "." \
    -Itool/lib -rfileutils -rbundled_gem -answ \
    -e 'BEGIN {FileUtils.mkdir_p(d = ".bundle/gems")}' \
    -e 'gem, ver, _, rev = *$F' \
    -e 'next if !ver or /^#/=~gem' \
    -e 'g = "#{gem}-#{ver}"' \
    -e 'if File.directory?("#{d}/#{g}")' \
    -e 'elsif rev and File.exist?(gs = "gems/src/#{gem}/#{gem}.gemspec")' \
    -e   'BundledGem.copy(gs, ".bundle")' \
    -e 'else' \
    -e   'BundledGem.unpack("gems/#{g}.gem", ".bundle")' \
    -e 'end' \
    -e 'FileUtils.rm_rf("#{d}/#{g}/.github")' \
    gems/bundled_gems
pkg_config=x86_64-pc-linux-gnu-pkg-config && PKG_CONFIG_PATH=. ${pkg_config:-:} --print-errors ruby.tmp
mv -f ruby.tmp.pc ruby-3.1.pc
/usr/bin/ruby --disable=gems ./tool/file2lastrev.rb -q --revision.h --srcdir="." > revision.tmp
clang version 15.0.5
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/15/bin
Configuration file: /etc/clang/clang.cfg
Traceback (most recent call last):
	4: from -e:in `require'
	3: from /var/tmp/portage/dev-lang/ruby-3.1.3/work/ruby-3.1.3/tool/lib/bundled_gem.rb:2:in `<top (required)>'
	2: from /var/tmp/portage/dev-lang/ruby-3.1.3/work/ruby-3.1.3/tool/lib/bundled_gem.rb:2:in `require'
	1: from /usr/lib64/ruby/2.7.0/rubygems.rb:16:in `<top (required)>'
/usr/lib64/ruby/2.7.0/rubygems.rb:16:in `require': cannot load such file -- rubygems/compatibility (LoadError)
make: *** [uncommon.mk:1370: extract-gems-sequential] Error 1
make: *** Waiting for unfinished jobs....
 * ERROR: dev-lang/ruby-3.1.3::gentoo failed (install phase):
 *   emake failed
```

Seems odd it calls /usr/bin/ruby as well and not the just-built ruby?
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-12-11 02:09:53 UTC
(to be clear, not clang specific, users hit it with gcc)
Comment 4 quilosaq 2022-12-12 16:41:56 UTC
As a workaround while the ebuild is being patched (if applicable), it has helped me to do:
RUBY_TARGETS="ruby27" emerge -v --oneshot rubygems
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-01-07 10:15:54 UTC
*** Bug 890036 has been marked as a duplicate of this bug. ***
Comment 6 Greg Kubaryk 2023-04-09 23:34:12 UTC
*** Bug 904059 has been marked as a duplicate of this bug. ***
Comment 7 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-04-10 04:37:59 UTC
extract-gems-sequential is gone from Ruby 3.2, although it looks like it came back in master. It is in ruby 3.1.

We want the behaviour to be the same regardless of if ruby is or isn't already installed, even outside of this bug, just for determinism and avoiding confusing bugs.

When Ruby is installed already:
```
./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --datarootdir=/usr/share --docdir=/usr/share/doc/ruby-3.1.3 --htmldir=/usr/share/doc/ruby-3.1.3/html --libdir=/usr/lib64 --program-suffix=31 --with-soname=ruby31 --with-readline-dir=/usr --enable-shared --enable-pthread --disable-rpath --with-out-ext=win32,win32ole,dbm,tk --without-jemalloc --disable-jit-support --disable-socks --disable-dtrace --disable-install-doc --enable-ipv6 --disable-static --disable-install-static-library --without-static-linked-ext --disable-debug --enable-option-checking=no
checking for ruby... /usr/bin/ruby
[...]
   * BASERUBY -v:         ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5) \
                          [x86_64-linux]
---
>>> Source configured.
>>> Compiling source in /var/tmp/portage/dev-lang/ruby-3.1.3/work/ruby-3.1.3 ...
make -j16 V=1 'EXTLDFLAGS=-Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0' 'MJIT_CFLAGS=-O2 -pipe -march=x86-64 -frecord-gcc-switches -fno-diagnostics-color -fmessage-length=0 -fno-strict-aliasing' MJIT_OPTFLAGS= MJIT_DEBUGFLAGS= 
	BASERUBY = /usr/bin/ruby --disable=gems
[...]
```

When Ruby is not installed already:
```
./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --datarootdir=/usr/share --docdir=/usr/share/doc/ruby-3.1.4 --htmldir=/usr/share/doc/ruby-3.1.4/html --libdir=/usr/lib64 --program-suffix=31 --with-soname=ruby31 --with-readline-dir=/usr --enable-shared --enable-pthread --disable-rpath --with-out-ext=win32,win32ole,dbm,tk --without-jemalloc --enable-jit-support --disable-socks --disable-dtrace --disable-install-doc --enable-ipv6 --disable-static --disable-install-static-library --without-static-linked-ext --disable-debug --enable-option-checking=no
configure: loading site script /usr/share/config.site
configure: loading site script /usr/share/config.site.d/80crossdev.conf
checking for ruby... false
[...]
   * JIT support:         yes
   * man page type:       doc

```

I think we can try the simple 'RUBY=false' and see what happens.
Comment 8 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-04-10 04:38:54 UTC
(In reply to Sam James from comment #7)
> I think we can try the simple 'RUBY=false' and see what happens.

... or let's just try --without-baseruby. Note that for cross in future, we might need to provide a baseruby, but let's not worry about that right now.
Comment 9 Larry the Git Cow gentoo-dev 2023-04-10 04:53:18 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cb9cc405d80a17e2b5329672c871e24d82cfb61e

commit cb9cc405d80a17e2b5329672c871e24d82cfb61e
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-04-10 04:51:12 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-04-10 04:52:35 +0000

    dev-lang/ruby: don't use baseruby; add HPPA-only fix
    
    1. Disable use of baseruby. This causes breakage if a previous Ruby is installed
    without rubygems like in bug #883097. We've had issues like this in the past
    in bug #787137 too.
    
    2. Add a fix which is ifdef'd for HPPA (upstream variant isn't, but let's
    be more conservative until it's merged there) to fix stack size allocation. This
    fixes tests for both Ruby and a bunch of Ruby packages.
    
    Bug: https://bugs.gentoo.org/787137
    Closes: https://bugs.gentoo.org/701494
    Closes: https://bugs.gentoo.org/883097
    Signed-off-by: Sam James <sam@gentoo.org>

 .../files/2.7/902-hppa-pthread-stack-size.patch    |  54 ++++
 .../files/3.0/902-hppa-pthread-stack-size.patch    |  54 ++++
 .../files/3.1/902-hppa-pthread-stack-size.patch    |  54 ++++
 .../files/3.2/902-hppa-pthread-stack-size.patch    |  54 ++++
 dev-lang/ruby/ruby-2.7.8-r1.ebuild                 | 274 +++++++++++++++++++++
 dev-lang/ruby/ruby-3.0.6-r1.ebuild                 | 269 ++++++++++++++++++++
 dev-lang/ruby/ruby-3.1.4-r1.ebuild                 | 253 +++++++++++++++++++
 dev-lang/ruby/ruby-3.2.2-r1.ebuild                 | 272 ++++++++++++++++++++
 8 files changed, 1284 insertions(+)