Closed beqdot closed 7 months ago
@beqdot Thanks for opening this issue. We do test the precompiled native gems on x86_64 musl, and it works fine there. I'll need to investigate why aarch64 is behaving differently.
Here's how I reproduced:
# with qemu installed on my host system
$ docker run --platform=linux/arm64/v8 -it ruby:3.1-alpine /bin/sh
/ # uname -a
Linux 9d91e7b6c79a 5.15.0-56-lowlatency #62~20.04.1-Ubuntu SMP PREEMPT Wed Nov 23 14:09:15 UTC 2022 aarch64 Linux
/ # apk add gcompat
fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/main/aarch64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/community/aarch64/APKINDEX.tar.gz
(1/3) Installing musl-obstack (1.2.3-r0)
(2/3) Installing libucontext (1.2-r0)
(3/3) Installing gcompat (1.1.0-r0)
OK: 25 MiB in 39 packages
/ # gem install sqlite3
Fetching sqlite3-1.5.4-aarch64-linux.gem
Successfully installed sqlite3-1.5.4-aarch64-linux
/ # ruby -rsqlite3 -e 'puts SQLite3::SQLITE_LOADED_VERSION'
<internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from /usr/local/bundle/gems/sqlite3-1.5.4-aarch64-linux/lib/sqlite3.rb:6:in `rescue in <top (required)>'
from /usr/local/bundle/gems/sqlite3-1.5.4-aarch64-linux/lib/sqlite3.rb:2:in `<top (required)>'
from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:160:in `require'
from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:160:in `rescue in require'
from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:149:in `require'
<internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require': Error relocating /usr/local/bundle/gems/sqlite3-1.5.4-aarch64-linux/lib/sqlite3/3.1/sqlite3_native.so: fcntl64: symbol not found - /usr/local/bundle/gems/sqlite3-1.5.4-aarch64-linux/lib/sqlite3/3.1/sqlite3_native.so (LoadError)
from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from /usr/local/bundle/gems/sqlite3-1.5.4-aarch64-linux/lib/sqlite3.rb:4:in `<top (required)>'
from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:160:in `require'
from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:160:in `rescue in require'
from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:149:in `require'
<internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- sqlite3 (LoadError)
from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
Please follow #442 for the fix-in-progress for this issue.
Should be fixed in v2.0.0 with the linux-musl native gem.
I'm using docker with Ruby alpine 3.1 image (on Mac M2 if that matters) and got this error:
The same situation happened with the gem 'nokogiri', but this is solved by adding gcompat lib (solution from docs https://nokogiri.org/tutorials/installing_nokogiri.html#linux-musl-error-loading-shared-library).
Now I make it with
gem install sqlite3 --platform=ruby
but native build could be much better for build time