Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support musl platforms: LoadError on aarch64-linux-musl #372

Closed
beqdot opened this issue Jan 7, 2023 · 3 comments · Fixed by #442
Closed

Support musl platforms: LoadError on aarch64-linux-musl #372

beqdot opened this issue Jan 7, 2023 · 3 comments · Fixed by #442

Comments

@beqdot
Copy link

beqdot commented Jan 7, 2023

I'm using docker with Ruby alpine 3.1 image (on Mac M2 if that matters) and got this error:

/usr/local/bundle/gems/activesupport-6.1.7/lib/active_support/dependencies.rb:332:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
...
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)

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

@flavorjones
Copy link
Member

@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'

@flavorjones
Copy link
Member

Please follow #442 for the fix-in-progress for this issue.

This was referenced Jan 23, 2024
@flavorjones
Copy link
Member

Should be fixed in v2.0.0 with the linux-musl native gem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants