Closed eregon closed 2 years ago
It's the same error on CRuby 3.0.2:
$ ruby -v -rsqlite3 -e 'db = SQLite3::Database.new "test.db"; p db'
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]
ruby: symbol lookup error: /home/eregon/.rubies/ruby-3.0.2/lib/ruby/gems/3.0.0/gems/sqlite3-1.3.13/lib/sqlite3/sqlite3_native.so: undefined symbol: rb_check_safe_obj
I just missed it above because there was a newer sqlite3 1.4.2 installed, and so -rsqlite3
picked that.
This is fixed in sqlite3 1.4.2: https://github.com/sparklemotion/sqlite3-ruby/blob/194493be44cd41b73e612eed69ba49354f0d32e7/CHANGELOG.rdoc https://github.com/sparklemotion/sqlite3-ruby/blob/v1.4.2/ext/sqlite3/database.c#L43
Problematic code was: https://github.com/sparklemotion/sqlite3-ruby/blob/v1.3.13/ext/sqlite3/database.c#L60
And there is a compile-time warning:
database.c: In function ‘initialize’:
database.c:60:3: warning: implicit declaration of function ‘rb_check_safe_obj’; did you mean ‘rb_check_safe_str’? [-Wimplicit-function-declaration]
60 | rb_check_safe_obj(file);
| ^~~~~~~~~~~~~~~~~
| rb_check_safe_str
But unfortunately gem install
completely hides this, unless using -V
(gem i -V sqlite3
).
Same for bundle install
.
Maybe CRuby and/or TruffleRuby should have -Werror=implicit-function-declaration
by default.
CRuby issue to address this https://bugs.ruby-lang.org/issues/18615
CRuby 3.2+ will use -Werror=implicit-function-declaration
, and TruffleRuby will add it for the 22.2 release.
See https://github.com/thoughtbot/factory_bot/runs/5458798971?check_suite_focus=true and https://github.com/thoughtbot/factory_bot/issues/1529#issuecomment-1061727535
Rails 5 is anyway not supported with Ruby 3+ so that part does not matter (https://github.com/rails/rails/issues/40938), but it'd still be good to understand why this error happens, and it seems to be different on CRuby.