Gem installation fails on JRuby 9.4 and 10.0
Not sure if it's a JRuby issue or an sqlite3 issue, but the problem looks similar to this one, only it occurs not on rockylinux but on Ubuntu and with the latest versions of sqlite3 and sqlite3-ruby. The failures started to occur on November 17.
The Dockerfile to reproduce the issue will be pasted at the end of the description.
Steps to reproduce:
- Run a container using the attached Dockerfile
- Set the ruby version to jruby-9.4.14.0 (
~/.rbenv/bin/rbenv local jruby-9.4.14.0). Make sure it worked by runningruby -v. - Try to install sqlite3:
gem install sqlite3
Expected behavior: gem is installed without any issues.
Actual behavior:
$ gem install sqlite3
Fetching sqlite3-2.8.0.gem
Fetching mini_portile2-2.8.9.gem
Successfully installed mini_portile2-2.8.9
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
current directory: /home/user/.rbenv/versions/jruby-9.4.14.0/lib/ruby/gems/shared/gems/sqlite3-2.8.0/ext/sqlite3
/home/user/.rbenv/versions/jruby-9.4.14.0/bin/jruby extconf.rb
Building sqlite3-ruby using packaged sqlite3.
Extracting sqlite-autoconf-3510000.tar.gz into tmp/x86_64-linux-gnu/ports/sqlite3/3.51.0... OK
Running 'configure' for sqlite3 3.51.0... OK
Running 'compile' for sqlite3 3.51.0... OK
Running 'install' for sqlite3 3.51.0... OK
Activating sqlite3 3.51.0 (from /home/user/.rbenv/versions/jruby-9.4.14.0/lib/ruby/gems/shared/gems/sqlite3-2.8.0/ports/x86_64-linux-gnu/sqlite3/3.51.0)...
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/user/.rbenv/versions/jruby-9.4.14.0/bin/jruby
--help
--download-dependencies
--with-sqlcipher
--without-sqlcipher
--with-sqlcipher-dir
--without-sqlcipher-dir
--with-sqlcipher-include
--without-sqlcipher-include
--with-sqlcipher-lib
--without-sqlcipher-lib
--enable-system-libraries
--disable-system-libraries
--with-sqlcipher
--without-sqlcipher
--with-sqlcipher-dir
--without-sqlcipher-dir
--with-sqlcipher-include
--without-sqlcipher-include
--with-sqlcipher-lib
--without-sqlcipher-lib
--with-sqlite-source-dir
--with-sqlite-cflags
--without-sqlite-cflags
--with-/home/user/.rbenv/versions/jruby-9.4.14.0/lib/ruby/gems/shared/gems/sqlite3-2.8.0/ports/x86_64-linux-gnu/sqlite3/3.51.0/lib/pkgconfig/sqlite3.pc-config
--without-/home/user/.rbenv/versions/jruby-9.4.14.0/lib/ruby/gems/shared/gems/sqlite3-2.8.0/ports/x86_64-linux-gnu/sqlite3/3.51.0/lib/pkgconfig/sqlite3.pc-config
--with-pkg-config
--without-pkg-config
RuntimeError: The compiler failed to generate an executable file.
You have to install development tools first.
try_do at /home/user/.rbenv/versions/jruby-9.4.14.0/lib/ruby/stdlib/mkmf.rb:456
try_link0 at /home/user/.rbenv/versions/jruby-9.4.14.0/lib/ruby/stdlib/mkmf.rb:541
try_link at /home/user/.rbenv/versions/jruby-9.4.14.0/lib/ruby/stdlib/mkmf.rb:556
try_ldflags at /home/user/.rbenv/versions/jruby-9.4.14.0/lib/ruby/stdlib/mkmf.rb:657
pkg_config at /home/user/.rbenv/versions/jruby-9.4.14.0/lib/ruby/stdlib/mkmf.rb:1813
configure_packaged_libraries at extconf.rb:86
tap at <internal:uri:classloader:/jruby/kernel/kernel.rb>:19
configure_packaged_libraries at extconf.rb:51
configure at extconf.rb:17
<main> at extconf.rb:297
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/user/.rbenv/versions/jruby-9.4.14.0/lib/ruby/gems/shared/extensions/universal-java-8/3.1.0/sqlite3-2.8.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/user/.rbenv/versions/jruby-9.4.14.0/lib/ruby/gems/shared/gems/sqlite3-2.8.0 for inspection.
Results logged to /home/user/.rbenv/versions/jruby-9.4.14.0/lib/ruby/gems/shared/extensions/universal-java-8/3.1.0/sqlite3-2.8.0/gem_make.out
A new release of RubyGems is available: 3.6.9 → 3.7.2!
Run `gem update --system 3.7.2` to update your installation.
The content of mkmf.log:
$ cat /home/user/.rbenv/versions/jruby-9.4.14.0/lib/ruby/gems/shared/extensions/universal-java-8/3.1.0/sqlite3-2.8.0/mkmf.log
"pkg-config --exists /home/user/.rbenv/versions/jruby-9.4.14.0/lib/ruby/gems/shared/gems/sqlite3-2.8.0/ports/x86_64-linux-gnu/sqlite3/3.51.0/lib/pkgconfig/sqlite3.pc"
| pkg-config --libs /home/user/.rbenv/versions/jruby-9.4.14.0/lib/ruby/gems/shared/gems/sqlite3-2.8.0/ports/x86_64-linux-gnu/sqlite3/3.51.0/lib/pkgconfig/sqlite3.pc
=> "-lsqlite3 \n"
" -o conftest -I/include/universal-java-8 -I/home/user/.rbenv/versions/jruby-9.4.14.0/lib/ruby/include/ruby/backward -I/home/user/.rbenv/versions/jruby-9.4.14.0/lib/ruby/include -I. -fno-omit-frame-pointer -fno-strict-aliasing -fexceptions conftest.c -L. -L/home/user/.rbenv/versions/jruby-9.4.14.0/lib -m64 "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <ruby.h>
4: int main(int argc, char **argv)
5: {
6: return 0;
7: }
/* end */
The issue is only reproducible with JRuby, not with regular Ruby (tried the version 3.4.5). It's also reproducible with JRuby 10, but you'll have to install JDK 21 first to be able to verify that. As you can see from the output, the sqlite3-ruby version is 2.8.0 and the sqlite3 version linked to it is 3.51.0.
Dockerfile to reproduce:
FROM ubuntu:24.04
USER root
# Software update & install
RUN apt update && apt upgrade -y && apt install curl sudo gnupg2 -y
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
RUN curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -
RUN apt update && apt -y upgrade
RUN sudo bash -c 'export DEBIAN_FRONTEND=noninteractive && \
ln -fs /usr/share/zoneinfo/Europe/Berlin /etc/localtime && \
apt-get install -y tzdata && \
dpkg-reconfigure --frontend noninteractive tzdata'
RUN apt install -y software-properties-common gcc cmake mc openssh-server zlib1g-dev build-essential \
libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev \
libffi-dev ruby ruby-dev nodejs libmysqlclient-dev git rsync rsyslog gawk autoconf automake bison \
libgdbm-dev libncurses5-dev libtool pkg-config openjdk-8-jdk-headless libice-dev libice6 libpthread-stubs0-dev \
libsm-dev libsm6 libx11-dev libx11-doc libxau-dev libxcb1-dev libxdmcp-dev libxt-dev libxt6 x11proto-core-dev \
x11proto-input-dev x11proto-kb-dev xorg-sgml-doctools xtrans-dev language-pack-en yarn apt-utils lsof gdb && \
apt autoremove -y && apt clean all
# Creating user:user
RUN echo 'root:root' | chpasswd
RUN adduser --uid 1001 user --disabled-password --gecos "User"
RUN usermod -aG sudo user
RUN echo 'user:user' | chpasswd
RUN echo 'user ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER user
# English locale
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:
# Configuring sshd
EXPOSE 22
USER root
RUN mkdir /var/run/sshd && chmod 0755 /var/run/sshd
RUN echo "# Package generated configuration file\n# See the sshd_config(5) manpage for details\n\n# What ports, IPs and protocols we listen for\nPort 22\n# Use these options to restrict which interfaces/protocols sshd will bind to\n#ListenAddress ::\n#ListenAddress 0.0.0.0\nProtocol 2\n# HostKeys for protocol version 2\nHostKey /etc/ssh/ssh_host_rsa_key\nHostKey /etc/ssh/ssh_host_dsa_key\nHostKey /etc/ssh/ssh_host_ecdsa_key\nHostKey /etc/ssh/ssh_host_ed25519_key\n#Privilege Separation is turned on for security\nUsePrivilegeSeparation yes\n\n# Lifetime and size of ephemeral version 1 server key\nKeyRegenerationInterval 3600\nServerKeyBits 1024\n\n# Logging\nSyslogFacility AUTH\nLogLevel INFO\n\n# Authentication:\nLoginGraceTime 120\nPermitRootLogin yes\n#without-password\nStrictModes yes\n\nRSAAuthentication yes\nPubkeyAuthentication yes\n#AuthorizedKeysFile %h/.ssh/authorized_keys\n\n# Don't read the user's ~/.rhosts and ~/.shosts files\nIgnoreRhosts yes\n# For this to work you will also need host keys in /etc/ssh_known_hosts\nRhostsRSAAuthentication no\n# similar for protocol version 2\nHostbasedAuthentication no\n# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication\n#IgnoreUserKnownHosts yes\n\n# To enable empty passwords, change to yes (NOT RECOMMENDED)\nPermitEmptyPasswords no\n\n# Change to yes to enable challenge-response passwords (beware issues with\n# some PAM modules and threads)\nChallengeResponseAuthentication no\n\n# Change to no to disable tunnelled clear text passwords\n#PasswordAuthentication yes\n\n# Kerberos options\n#KerberosAuthentication no\n#KerberosGetAFSToken no\n#KerberosOrLocalPasswd yes\n#KerberosTicketCleanup yes\n\n# GSSAPI options\n#GSSAPIAuthentication no\n#GSSAPICleanupCredentials yes\n\nX11Forwarding yes\nX11DisplayOffset 10\nPrintMotd no\nPrintLastLog yes\nTCPKeepAlive yes\n#UseLogin no\n\n#MaxStartups 10:30:60\n#Banner /etc/issue.net\n\n# Allow client to pass locale environment variables\nAcceptEnv LANG LC_*\n\nSubsystem sftp /usr/lib/openssh/sftp-server\n\n# Set this to 'yes' to enable PAM authentication, account processing,\n# and session processing. If this is enabled, PAM authentication will\n# be allowed through the ChallengeResponseAuthentication and\n# PasswordAuthentication. Depending on your PAM configuration,\n# PAM authentication via ChallengeResponseAuthentication may bypass\n# the setting of PermitRootLogin without-password.\n# If you just want the PAM account and session checks to run without\n# PAM authentication, then enable this but set PasswordAuthentication\n# and ChallengeResponseAuthentication to 'no'.\nUsePAM yes\n" > /etc/ssh/sshd_config
USER user
# Installing cargo, rust and rbspy
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
RUN ~/.cargo/bin/cargo --version
RUN ~/.cargo/bin/cargo install rbspy --locked
RUN sudo mv ~/.cargo/bin/rbspy /usr/local/bin/
RUN rbspy --version
RUN gem install irb --user-install
#
USER user
WORKDIR /home/user
# with-rbenv
# installing rbenv
RUN git clone https://github.com/rbenv/rbenv.git ~/.rbenv
RUN cd ~/.rbenv && src/configure && make -C src
RUN echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
RUN echo 'eval "$(rbenv init -)"' >> ~/.bashrc
RUN echo 'export PATH="$HOME/.rbenv/shims:$PATH"' >> ~/.profile
# installing rbenv-gemset
RUN git clone https://github.com/jf/rbenv-gemset.git ~/.rbenv/plugins/rbenv-gemset
# installing ruby-build
RUN git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
ENV RUBY_CONFIGURE_OPTS="--disable-install-doc"
ENV MAKEOPTS="-j 8"
# fix for rbenv jruby issue (shims path missing)
ENV PATH="/home/user/.rbenv/shims:${PATH}"
RUN bash -l -c 'cd ~/.rbenv && git pull && cd plugins/ruby-build && git pull'
ENV _RUBY_VERSION=jruby-9.4.14.0
RUN bash -l -c '~/.rbenv/bin/rbenv install $_RUBY_VERSION && \
RBENV_VERSION=$_RUBY_VERSION ~/.rbenv/bin/rbenv exec gem update --system --no-document && \
RBENV_VERSION=$_RUBY_VERSION ~/.rbenv/bin/rbenv exec gem uninstall rubygems-update'
RUN bash -l -c "RBENV_VERSION=$_RUBY_VERSION ~/.rbenv/bin/rbenv exec gem install jar-dependencies --no-document"