镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

gem install sqlite3 --platform=ruby fails to build starting at 2.6.0 #634

Closed

Description

@copiousfreetime

Installing the ruby platform gem

Admittedly I'm doing this on an older linux -- rockylinux 8.6 -- which is linux kernel 5.19.11-1ep.el8.x86_64 and glibc 2.28.

But that shouldn't affect a working ruby 3.4.4, from building sqlite3.

It does look like this started with sqlite3 2.6.0 which is also when the autotools was changed to autosetup -- so I wonder if that is actually the issue.

Gem Environment

RubyGems Environment:
  - RUBYGEMS VERSION: 3.6.9
  - RUBY VERSION: 3.4.4 (2025-05-14 patchlevel 34) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/vagrant/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0
  - USER INSTALLATION DIRECTORY: /home/vagrant/.gem/ruby/3.4.0
  - CREDENTIALS FILE: /home/vagrant/.local/share/gem/credentials
  - RUBY EXECUTABLE: /home/vagrant/.rbenv/versions/3.4.4/bin/ruby
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /home/vagrant/.rbenv/versions/3.4.4/bin
  - SPEC CACHE DIRECTORY: /home/vagrant/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /home/vagrant/.rbenv/versions/3.4.4/etc
  - RUBYGEMS PLATFORMS:
     - ruby
     - x86_64-linux
  - GEM PATHS:
     - /home/vagrant/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0
     - /home/vagrant/.gem/ruby/3.4.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - :sources => ["https://rubygems.org"]
     - :concurrent_downloads => 8
     - "benchmark" => false
     - "gem" => "--no-ri --no-rdoc"
  - REMOTE SOURCES:
     - https://rubygems.org

gem intall sqlite3 --platformr=ruby -v 2.6.0

Building native extensions. This could take a while...
ERROR:  Error installing sqlite3:
        ERROR: Failed to build gem native extension.

    current directory: /home/vagrant/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0/gems/sqlite3-2.6.0/ext/sqlite3
/home/vagrant/.rbenv/versions/3.4.4/bin/ruby extconf.rb
Building sqlite3-ruby using packaged sqlite3.
Extracting sqlite-autoconf-3490100.tar.gz into tmp/x86_64-redhat-linux/ports/sqlite3/3.49.1... OK
Running 'configure' for sqlite3 3.49.1... OK
Running 'compile' for sqlite3 3.49.1... OK
Running 'install' for sqlite3 3.49.1... OK
Activating sqlite3 3.49.1 (from /home/vagrant/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0/gems/sqlite3-2.6.0/ports/x86_64-redhat-linux/sqlite3/3.49.1)...
checking for pkg-config for /home/vagrant/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0/gems/sqlite3-2.6.0/ports/x86_64-redhat-linux/sqlite3/3.49.1/lib/pkgconfig/sqlite3.pc... ["-I/home/vagrant/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0/gems/sqlite3-2.6.0/ports/x86_64-redhat-linux/sqlite3/3.49.1/include ", "", "-lsqlite3"]
checking for whether -L/home/vagrant/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0/gems/sqlite3-2.6.0/ports/x86_64-redhat-linux/sqlite3/3.49.1/lib is accepted as LDFLAGS... yes
checking for whether -lsqlite3 is accepted as LDFLAGS... yes
checking for whether -lm is accepted as LDFLAGS... yes
checking for whether -lz is accepted as LDFLAGS... yes
checking for whether -DUSING_PACKAGED_LIBRARIES is accepted as CPPFLAGS... yes
checking for whether -fvisibility=hidden is accepted as CFLAGS... yes
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... no

Could not find sqlite3.
Please visit https://github.com/sparklemotion/sqlite3-ruby for installation instructions.


*** 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=${opt-dir}/include
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/home/vagrant/.rbenv/versions/3.4.4/bin/$(RUBY_BASE_NAME)
        --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/vagrant/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0/gems/sqlite3-2.6.0/ports/x86_64-redhat-linux/sqlite3/3.49.1/lib/pkgconfig/sqlite3.pc-dir
        --without-/home/vagrant/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0/gems/sqlite3-2.6.0/ports/x86_64-redhat-linux/sqlite3/3.49.1/lib/pkgconfig/sqlite3.pc-dir
        --with-/home/vagrant/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0/gems/sqlite3-2.6.0/ports/x86_64-redhat-linux/sqlite3/3.49.1/lib/pkgconfig/sqlite3.pc-include=${/home/vagrant/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0/gems/sqlite3-2.6.0/ports/x86_64-redhat-linux/sqlite3/3.49.1/lib/pkgconfig/sqlite3.pc-dir}/include
        --without-/home/vagrant/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0/gems/sqlite3-2.6.0/ports/x86_64-redhat-linux/sqlite3/3.49.1/lib/pkgconfig/sqlite3.pc-include
        --with-/home/vagrant/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0/gems/sqlite3-2.6.0/ports/x86_64-redhat-linux/sqlite3/3.49.1/lib/pkgconfig/sqlite3.pc-lib=${/home/vagrant/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0/gems/sqlite3-2.6.0/ports/x86_64-redhat-linux/sqlite3/3.49.1/lib/pkgconfig/sqlite3.pc-dir}/lib
        --without-/home/vagrant/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0/gems/sqlite3-2.6.0/ports/x86_64-redhat-linux/sqlite3/3.49.1/lib/pkgconfig/sqlite3.pc-lib
        --with-/home/vagrant/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0/gems/sqlite3-2.6.0/ports/x86_64-redhat-linux/sqlite3/3.49.1/lib/pkgconfig/sqlite3.pc-config
        --without-/home/vagrant/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0/gems/sqlite3-2.6.0/ports/x86_64-redhat-linux/sqlite3/3.49.1/lib/pkgconfig/sqlite3.pc-config
        --with-pkg-config
        --without-pkg-config
        --enable-cross-build
        --disable-cross-build
        --with-sqlcipher
        --without-sqlcipher
        --with-sqlcipher-dir
        --without-sqlcipher-dir
        --with-sqlcipher-include
        --without-sqlcipher-include
        --with-sqlcipher-lib
        --without-sqlcipher-lib
        --with-sqlite3-dir
        --without-sqlite3-dir
        --with-sqlite3-include=${sqlite3-dir}/include
        --without-sqlite3-include
        --with-sqlite3-lib=${sqlite3-dir}/lib
        --without-sqlite3-lib
        --with-sqlite3lib
        --without-sqlite3lib
        --with-sqlcipher
        --without-sqlcipher
        --with-sqlcipher-dir
        --without-sqlcipher-dir
        --with-sqlcipher-include
        --without-sqlcipher-include
        --with-sqlcipher-lib
        --without-sqlcipher-lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/vagrant/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0/extensions/x86_64-linux/3.4.0/sqlite3-2.6.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/vagrant/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0/gems/sqlite3-2.6.0 for inspection.
Results logged to /home/vagrant/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0/extensions/x86_64-linux/3.4.0/sqlite3-2.6.0/gem_make.out

Last working version 2.5.0

% gem install sqlite3 --platform=ruby  -v 2.5.0
Building native extensions. This could take a while...
Successfully installed sqlite3-2.5.0
Parsing documentation for sqlite3-2.5.0
Done installing documentation for sqlite3 after 3 seconds
1 gem installed

Activity

  1. copiousfreetime commented on Jul 3, 2025

    @copiousfreetime
    Author

    I did decide to attempt to build from the sqlite3-ruby release tarball using the source release, and this also failed.

    vagrant@podman:~/tmp/sqlite3-ruby-2.6.0 3.4.3 % bundle exec rake compile
    mkdir -p tmp/x86_64-linux/sqlite3_native/3.4.3
    cd tmp/x86_64-linux/sqlite3_native/3.4.3
    /home/vagrant/.rbenv/versions/3.4.3/bin/ruby -I. ../../../../ext/sqlite3/extconf.rb
    Building sqlite3-ruby using packaged sqlite3.
    Downloading sqlite-autoconf-3490100.tar.gz (100%)
    Extracting sqlite-autoconf-3490100.tar.gz into tmp/x86_64-redhat-linux/ports/sqlite3/3.49.1... OK
    Running 'configure' for sqlite3 3.49.1... OK
    Running 'compile' for sqlite3 3.49.1... OK
    Running 'install' for sqlite3 3.49.1... OK
    Activating sqlite3 3.49.1 (from /home/vagrant/tmp/sqlite3-ruby-2.6.0/ports/x86_64-redhat-linux/sqlite3/3.49.1)...
    checking for pkg-config for /home/vagrant/tmp/sqlite3-ruby-2.6.0/ports/x86_64-redhat-linux/sqlite3/3.49.1/lib/pkgconfig/sqlite3.pc... ["-I/home/vagrant/tmp/sqlite3-ruby-2.6.0/ports/x86_64-redhat-linux/sqlite3/3.49.1/include ", "", "-lsqlite3"]
    checking for whether -L/home/vagrant/tmp/sqlite3-ruby-2.6.0/ports/x86_64-redhat-linux/sqlite3/3.49.1/lib is accepted as LDFLAGS... yes
    checking for whether -lsqlite3 is accepted as LDFLAGS... yes
    checking for whether -lm is accepted as LDFLAGS... yes
    checking for whether -lz is accepted as LDFLAGS... yes
    checking for whether -DUSING_PACKAGED_LIBRARIES is accepted as CPPFLAGS... yes
    checking for whether -fvisibility=hidden is accepted as CFLAGS... yes
    checking for sqlite3.h... yes
    checking for sqlite3_libversion_number() in -lsqlite3... no
    
    Could not find sqlite3.
    

    In order to double check that this is an issue in the ruby extension, I also downloaded the same sqlite3 tarball above from sqlite and ran its build:

    
    Line-editing support for the sqlite3 shell: none
    Checking libs for dlopen...-ldl
    Loadable extension support enabled.
    Checking libs for ceil...-lm
    Enabling math SQL functions -lm
    ICU support is disabled.
    Feature flags...
      - fts4
      + fts5
      - geopoly
      - rtree
      - session
      - update-limit
      - memsys5
      - memsys3
      - scanstatus
      + json
    Library feature flags: -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_THREADSAFE=1
    Shell options: -DSQLITE_HAVE_ZLIB=1
    Makefile is unchanged
    sqlite3.pc is unchanged
    sqlite_cfg.h is unchanged
    
    vagrant@podman:~/tmp/sqlite-autoconf-3490100 3.4.3 % ./configure  "--enable-static" "--disable-shared" "--disable-shared" "--enable-static" "--enable-fts5" "CC=gcc" "CFLAGS=-fPIC -O2 -fvisibility=hidden -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_USE_URI=1 -DSQLITE_ENABLE_DBPAGE_VTAB=1 -DSQLITE_ENABLE_DBSTAT_VTAB=1"
    Host System...x86_64-pc-linux-gnu
    Build System...x86_64-pc-linux-gnu
    C compiler... gcc -fPIC -O2 -fvisibility=hidden -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_USE_URI=1 -DSQLITE_ENABLE_DBPAGE_VTAB=1 -DSQLITE_ENABLE_DBSTAT_VTAB=1
    C++ compiler... c++ -fPIC -O2 -fvisibility=hidden -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_USE_URI=1 -DSQLITE_ENABLE_DBPAGE_VTAB=1 -DSQLITE_ENABLE_DBSTAT_VTAB=1
    Build C compiler...cc
    Checking for stdlib.h...ok
    Source dir = /home/vagrant/tmp/sqlite-autoconf-3490100
    Build dir  = /home/vagrant/tmp/sqlite-autoconf-3490100
    Configuring SQLite version 3.49.1
    Looking for install ... /usr/bin/install
    Checking for int8_t...ok
    Checking for int16_t...ok
    Checking for int32_t...ok
    Checking for int64_t...ok
    Checking for intptr_t...ok
    Checking for uint8_t...ok
    Checking for uint16_t...ok
    Checking for uint32_t...ok
    Checking for uint64_t...ok
    Checking for uintptr_t...ok
    Checking for gmtime_r...ok
    Checking for isnan...ok
    Checking for localtime_r...ok
    Checking for localtime_s...not found
    Checking for malloc_usable_size...ok
    Checking for strchrnul...ok
    Checking for usleep...ok
    Checking for utime...ok
    Checking for pread...ok
    Checking for pread64...ok
    Checking for pwrite...ok
    Checking for pwrite64...ok
    Checking libs for fdatasync...none needed
    Checking libs for nanosleep...none needed
    Checking for sys/types.h...ok
    Checking for sys/stat.h...ok
    Checking for dlfcn.h...ok
    Checking for unistd.h...ok
    Checking for stdlib.h...(cached) ok
    Checking for malloc.h...ok
    Checking for memory.h...ok
    Checking for string.h...ok
    Checking for strings.h...ok
    Checking for inttypes.h...ok
    Checking for zlib.h...ok
    Checking libs for deflate...-lz
    Checking whether the C compiler accepts -rpath /usr/local/lib...no
    Checking whether the C compiler accepts -Wl,-rpath,/usr/local/lib...yes
    SQLITE_DEBUG build? no
    Support threadsafe operation? Checking for libs...
    Checking libs for pthread_create...-lpthread
    Checking libs for pthread_mutexattr_init...-lpthread
    Checking for line-editing capability...
    Line-editing support for the sqlite3 shell: none
    Checking libs for dlopen...-ldl
    Loadable extension support enabled.
    Checking libs for ceil...-lm
    Enabling math SQL functions -lm
    ICU support is disabled.
    Feature flags...
      - fts4
      + fts5
      - geopoly
      - rtree
      - session
      - update-limit
      - memsys5
      - memsys3
      - scanstatus
      + json
    Library feature flags: -DSQLITE_ENABLE_DBPAGE_VTAB=1 -DSQLITE_ENABLE_DBSTAT_VTAB=1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_THREADSAFE=1
    Shell options: -DSQLITE_HAVE_ZLIB=1
    Makefile is unchanged
    sqlite3.pc is unchanged
    sqlite_cfg.h is unchanged
    vagrant@podman:~/tmp/sqlite-autoconf-3490100 3.4.3 % make
    gcc -c /home/vagrant/tmp/sqlite-autoconf-3490100/sqlite3.c -o sqlite3.o -fPIC -O2 -fvisibility=hidden -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_USE_URI=1  -I. -fPIC  -DSQLITE_ENABLE_DBPAGE_VTAB=1 -DSQLITE_ENABLE_DBSTAT_VTAB=1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_THREADSAFE=1
    gcc -o libsqlite3.so  sqlite3.o -shared \
    	 -Wl,-rpath,/usr/local/lib -lpthread -lm -ldl -lz    \
    
    ar cr libsqlite3.a sqlite3.o
    gcc -o sqlite3 \
    	/home/vagrant/tmp/sqlite-autoconf-3490100/shell.c /home/vagrant/tmp/sqlite-autoconf-3490100/sqlite3.c -Wl,-rpath,/usr/local/lib -lpthread -lm -ldl -lz    \
    	-I. -DSQLITE_ENABLE_DBPAGE_VTAB=1 -DSQLITE_ENABLE_DBSTAT_VTAB=1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_THREADSAFE=1 -DSQLITE_HAVE_ZLIB=1 \
    	-fPIC -O2 -fvisibility=hidden -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_USE_URI=1    \
    
    vagrant@podman:~/tmp/sqlite-autoconf-3490100 3.4.3 % ./sqlite3
    SQLite version 3.49.1 2025-02-18 13:38:58
    Enter ".help" for usage hints.
    Connected to a transient in-memory database.
    Use ".open FILENAME" to reopen on a persistent database.
    sqlite> .quit
    

    And this runs fine.

  2. flavorjones commented on Jul 4, 2025

    @flavorjones
    Member

    Digging in now, thanks for providing enough detail to get started. Agree it seems likely to be related to the autoconf/autosetup change upstream.

  3. flavorjones commented on Jul 4, 2025

    @flavorjones
    Member

    Building a rockylinux:8.6 OCI image to try to reproduce.

  4. flavorjones commented on Jul 4, 2025

    @flavorjones
    Member

    I've reproduced using an image built with this Dockerfile:

    FROM rockylinux:8.6
    
    # build essentials
    RUN dnf update -y 
    RUN dnf install -y epel-release && dnf update -y
    RUN dnf config-manager --set-enabled powertools
    RUN dnf group install -y "Development Tools"
    RUN dnf install -y openssl-devel readline-devel zlib-devel libyaml-devel libffi-devel wget curl
    
    # mise and ruby
    RUN dnf install -y dnf-plugins-core && \
        dnf config-manager --add-repo https://mise.jdx.dev/rpm/mise.repo && \
        dnf install -y mise
    RUN mise install ruby@3.4.4
    
    # now run `mise exec ruby@3.4.4 -- gem install sqlite3 --platform=ruby`
  5. flavorjones commented on Jul 4, 2025

    @flavorjones
    Member

    OK, the mkmf.log you provided matches what I'm seeing locally:

    /usr/bin/ld: /root/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/sqlite3-2.7.1/ports/x86_64-redhat-linux/sqlite3/3.50.2/lib/libsqlite3.a(sqlite3.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
    //usr/lib64/libdl.so.2: error adding symbols: DSO missing from command line
    collect2: error: ld returned 1 exit status
    
  6. flavorjones commented on Jul 4, 2025

    @flavorjones
    Member

    OK, SQLite is getting built just fine, the issue is in linking the Ruby extension against it.

    Here's my diagnosis:

    1. on rockylinux, the symbol dlclose is in libdl.so
      /usr/lib64/libdl.so.2
      0000000000001090 g    DF .text  000000000000004a  GLIBC_2.2.5 dlclose
      
    2. while on debian/ubuntu it is in libc.so
      /usr/lib/x86_64-linux-gnu/libc.so.6
      000000000009e580 g    DF .text  000000000000003c (GLIBC_2.2.5) dlclose
      000000000009e580 g    DF .text  000000000000003c  GLIBC_2.34  dlclose
      
    3. the pkgconf file generated by SQLite in 3.48.0+, which is used to determine the linker flags used while building the extension, emits something like this on both rockylinux and debian:
      pkg-config --libs --static ./ports/x86_64-redhat-linux/sqlite3/3.50.2/lib/pkgconfig/sqlite3.pc
      -L/path/to/sqlite3/3.50.2/lib -lsqlite3 -lm -lz
      
      The thing to note is that -ldl is not present.
    4. the pkgconf file generate by SQLite 3.47.2 emits this on rockylinux:
      pkg-config --libs --static path/to/sqlite3.pc
      -L/path/to/sqlite3/3.47.2/lib -lsqlite3 -lz -lm -ldl -lpthread
      
      while on debian it emits the same as noted above, -lsqlite3 -lz -lm

    So I think what we're seeing is: on debian platforms, the dlclose symbol is found at linktime by its presence in libc; but on rockylinux, dlclose must be resolved by an explicit -ldl on the link line, which isn't present in the pkgconf file.

    In previous versions of SQLite, the -ldl (and -lpthread, though that's less of an issue because it's always present in Ruby's LIBS) were included in the pkgconf output, and so were linked against. In the current version (which as you noted was a change from autosetup) it's not present, and so you see these linker failures.

    Make sense?

    A couple of things we should do:

    • post about this upstream in the forum (which I'll do now) to see if they'll fix it
    • and then to work around this, one of:
      • add special handling for rockylinux (and, I'm assuming, possibly other redhat-derived distros?) to add this to the link line
      • add the general ability to inject linker flags through an environment variable or config option, and then you set those yourself at build time
      • always tack on -ldl on *nix systems (since Ruby needs those anyway, it shouldn't cause any problems) *

    Let's start by opening a forum post upstream and see what they say.

    * Edit: ah, can't add this library on Musl Linux platforms.

  7. flavorjones commented on Jul 4, 2025

    @flavorjones
    Member
  8. flavorjones commented on Jul 4, 2025

    @flavorjones
    Member

    Potential fix at #635

  9. flavorjones commented on Jul 4, 2025

    @flavorjones
    Member

    Upstream has fixed the issue on trunk, in response to the forum post: https://sqlite.org/src/info/64f5f14322, and so I've rewritten #635 to just apply that patch.

  10. flavorjones commented on Jul 5, 2025

    @flavorjones
    Member

    Fix shipped in v2.7.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions