activerecord-jdbc-adapter icon indicating copy to clipboard operation
activerecord-jdbc-adapter copied to clipboard

Rails 8 support

Open osbre opened this issue 6 months ago • 8 comments

Currently, this package appears to be incompatible with Rails 8:

$ jbundle
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Could not find compatible versions

Because activerecord-jdbc-adapter = 71.0 could not be found in rubygems
repository https://rubygems.org/ or installed locally for any resolution
platforms (universal-java-23)
  and activerecord-jdbc-adapter >= 71.0 depends on activerecord ~> 7.1.3,
  activerecord-jdbc-adapter >= 71.0 requires activerecord ~> 7.1.3.
And because rails >= 8.0.2 depends on activerecord = 8.0.2,
  activerecord-jdbc-adapter >= 71.0 is incompatible with rails >= 8.0.2.
So, because Gemfile depends on rails ~> 8.0.2
  and Gemfile depends on activerecord-jdbc-adapter = 71.0,
  version solving has failed.

The source contains the following gems matching 'activerecord-jdbc-adapter (=
71.0)':
  * activerecord-jdbc-adapter-71.0-java

My Gemfile:

gem 'activerecord-jdbc-adapter', '71.0', platforms: :jruby
gem 'activerecord-jdbcsqlite3-adapter', '71.0', platforms: :jruby

osbre avatar Apr 30 '25 21:04 osbre

I wonder how far off the 71.x versions are from working on 7.2 and 8.0. We know we need to catch up! The jump from 7.0 to 7.1 was surprisingly complicated.

headius avatar May 02 '25 01:05 headius

Just ran into this when upgrading a library to activerecord ~> 8.0. Also had to upgrade sqlite3 to ~> 2.0 for ActiveRecord 8.0 under CRuby, which might imply some extra work is needed for activerecord-jdbcsqlite3-adapter.

postmodern avatar May 26 '25 17:05 postmodern

@headius I am setting this up in my extensive test suite for omniauth-identity now. I have tests against heads of Ruby Engines, like JRuby, but also heads of all required and optional runtime dependencies (like active record, sqlite3, etc).

Please make the branch for 7.2, so 8.0 can be targeted by master, thus we can target them in builds, and start to see where the cracks are.

https://github.com/omniauth/omniauth-identity/pull/152

NOTE: blogging about this setup is one of the things I want to do to highlight the benefits of adding explicit, tested, JRuby support to libraries. 👍

pboling avatar Jun 04 '25 02:06 pboling

@pboling I just made a 72-stable. PRs for 8 can go against master now. Thanks for pointing it out.

enebo avatar Jun 05 '25 13:06 enebo

jdbc-sqlite3 fails to build on JRuby 10.0.0.1.

Stack Trace
>> BUNDLE_GEMFILE=/home/runner/work/omniauth-identity/omniauth-identity/gemfiles/ar_8_0.gemfile bundle
A gemspec development dependency (activerecord, >= 5) is being overridden by a Gemfile dependency (activerecord, ~> 8.0.2).
This behaviour may change in the future. Please remove either of them, or make sure they both have the same requirement
Fetching https://github.com/jruby/activerecord-jdbc-adapter.git
Fetching gem metadata from https://rubygems.org/............
Resolving dependencies...
Fetching jdbc-sqlite3 3.46.1.1
Fetching stringio 3.1.7 (java)
Installing stringio 3.1.7 (java)
Installing jdbc-sqlite3 3.46.1.1
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/gems/shared/bundler/gems/activerecord-jdbc-adapter-3d36773cf4de
/home/runner/.rubies/jruby-10.0.0.1/bin/jruby -rrubygems
/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/gems/shared/gems/rake-13.3.0/exe/rake
RUBYARCHDIR\=/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/gems/shared/bundler/gems/extensions/universal-java-21/3.4.0/activerecord-jdbc-adapter-3d36773cf4de
RUBYLIBDIR\=/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/gems/shared/bundler/gems/extensions/universal-java-21/3.4.0/activerecord-jdbc-adapter-3d36773cf4de
/usr/bin/javac -target 21 -source 21 -Xlint:unchecked -g -cp
"/home/runner/.rubies/jruby-10.0.0.1/lib/jruby.jar:jdbc-postgres/lib/postgresql-42.7.1.jar:jdbc-mysql/lib/mysql-connector-j-[9](https://github.com/omniauth/omniauth-identity/actions/runs/15500561602/job/43647253259#step:5:10).1.0.jar"
-d /tmp/d20250606-2380-3gxic3 src/java/arjdbc/ArJdbcModule.java
src/java/arjdbc/db2/DB2Module.java
src/java/arjdbc/db2/DB2RubyJdbcConnection.java src/java/arjdbc/h2/H2Module.java
src/java/arjdbc/h2/H2RubyJdbcConnection.java
src/java/arjdbc/hsqldb/HSQLDBModule.java
src/java/arjdbc/jdbc/AdapterJavaService.java src/java/arjdbc/jdbc/Callable.java
src/java/arjdbc/jdbc/ConnectionFactory.java
src/java/arjdbc/jdbc/DataSourceConnectionFactory.java
src/java/arjdbc/jdbc/DriverConnectionFactory.java
src/java/arjdbc/jdbc/DriverWrapper.java src/java/arjdbc/jdbc/JdbcResult.java
src/java/arjdbc/jdbc/RubyConnectionFactory.java
src/java/arjdbc/jdbc/RubyJdbcConnection.java
src/java/arjdbc/mssql/MSSQLModule.java
src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java
src/java/arjdbc/mysql/MySQLModule.java
src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java
src/java/arjdbc/oracle/OracleModule.java
src/java/arjdbc/oracle/OracleRubyJdbcConnection.java
src/java/arjdbc/postgresql/ByteaUtils.java
src/java/arjdbc/postgresql/PgDateTimeUtils.java
src/java/arjdbc/postgresql/PostgreSQLModule.java
src/java/arjdbc/postgresql/PostgreSQLResult.java
src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java
src/java/arjdbc/sqlite3/SQLite3Module.java
src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java
src/java/arjdbc/util/CallResultSet.java src/java/arjdbc/util/DateTimeUtils.java
src/java/arjdbc/util/ObjectSupport.java src/java/arjdbc/util/PG.java
src/java/arjdbc/util/QuotingUtils.java src/java/arjdbc/util/StringCache.java
src/java/arjdbc/util/StringHelper.java
error: invalid target release: 21
Usage: javac <options> <source files>
use --help for a list of possible options
rake aborted!
could not build .jar extension - compilation failure
org/jruby/ext/monitor/Monitor.java:85:in 'synchronize'
org/jruby/ext/monitor/Monitor.java:85:in 'synchronize'
org/jruby/ext/monitor/Monitor.java:85:in 'synchronize'
Tasks: TOP => default => jar => lib/arjdbc/jdbc/adapter_java.jar
(See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in
/home/runner/.rubies/jruby-[10](https://github.com/omniauth/omniauth-identity/actions/runs/15500561602/job/43647253259#step:5:11).0.0.1/lib/ruby/gems/shared/bundler/gems/activerecord-jdbc-adapter-3d36773cf4de
for inspection.
Results logged to
/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/gems/shared/bundler/gems/extensions/universal-java-21/3.4.0/activerecord-jdbc-adapter-3d36773cf4de/gem_make.out

/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/stdlib/rubygems/ext/builder.rb:126:in
'run'
/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/stdlib/rubygems/ext/rake_builder.rb:35:in
'build'
/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/stdlib/rubygems/ext/builder.rb:195:in
'build_extension'
/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/stdlib/rubygems/ext/builder.rb:229:in
'block in build_extensions'
  org/jruby/RubyArray.java:2079:in 'each'
/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/stdlib/rubygems/ext/builder.rb:226:in
'build_extensions'
/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/stdlib/rubygems/installer.rb:844:in
'build_extensions'
/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/stdlib/bundler/rubygems_gem_installer.rb:[11](https://github.com/omniauth/omniauth-identity/actions/runs/15500561602/job/43647253259#step:5:12)1:in
'build_extensions'
/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/stdlib/bundler/source/path/installer.rb:28:in
'post_install'
/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/stdlib/bundler/source/path.rb:234:in
'generate_bin'
/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/stdlib/bundler/source/git.rb:2[12](https://github.com/omniauth/omniauth-identity/actions/runs/15500561602/job/43647253259#step:5:13):in
'install'
/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/stdlib/bundler/installer/gem_installer.rb:55:in
'install'
/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/stdlib/bundler/installer/gem_installer.rb:17:in
'install_from_spec'
/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/stdlib/bundler/installer/parallel_installer.rb:[13](https://github.com/omniauth/omniauth-identity/actions/runs/15500561602/job/43647253259#step:5:14)3:in
'do_install'
/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/stdlib/bundler/installer/parallel_installer.rb:124:in
'block in worker_pool'
/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/stdlib/bundler/worker.rb:62:in
'apply_func'
/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/stdlib/bundler/worker.rb:57:in
'block in process_queue'
  org/jruby/RubyKernel.java:[16](https://github.com/omniauth/omniauth-identity/actions/runs/15500561602/job/43647253259#step:5:17)58:in 'loop'
/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/stdlib/bundler/worker.rb:54:in
'process_queue'
/home/runner/.rubies/jruby-10.0.0.1/lib/ruby/stdlib/bundler/worker.rb:90:in
'block in create_threads'

An error occurred while installing activerecord-jdbc-adapter (80.0), and Bundler
cannot continue.

In ar_8_0.gemfile:
  activerecord-jdbcsqlite3-adapter was resolved to 80.0, which depends on
    activerecord-jdbc-adapter

ref: https://github.com/omniauth/omniauth-identity/actions/runs/15500561602/job/43647253259

pboling avatar Jun 06 '25 22:06 pboling

@pboling: JRuby 10 needs Java 21+ now, but GitHub CI is still living in the Java 8 BC era.

I learned this ancient wisdom from @enebo yesterday and casted the necessary spell here: https://github.com/jruby/activerecord-jdbc-adapter/blob/master/.github/workflows/ruby.yml#L49-L53

No, you didn’t miss 13 versions, Java releases every 6 months. That’s why GTA 6 still isn’t out. Rockstar’s waiting for Java to stop.

seuros avatar Jun 07 '25 07:06 seuros

In my wandering around the internet for hours trying to get a clue about this, I stumbled on a bunch of Java 8 mentions, and each time I thought - "no way that's still relevant". 🤦 GHA is so disappointing.

🦺 Always wear a life jacket when you surf the net!

pboling avatar Jun 07 '25 08:06 pboling

Thanks for the patience and help everyone. I'm thinking it would be best for us to concentrate on Rails 8 support as much as possible given available resources, but I have no idea how much work is required for finishing 7.1, adding 7.2 support, and adding whatever else is needed for 8. I'm not the expert in this repo but I can take guidance!

headius avatar Jun 09 '25 09:06 headius

Hi folks, are there any plans to release a stable version supporting Rails 8 (or 8.1) soon?

thre-raritan avatar Nov 26 '25 08:11 thre-raritan