Skip to content

Separate Java version out of rbconfig 'arch'#9107

Merged
headius merged 1 commit intojruby:masterfrom
headius:no_arch_version
Dec 3, 2025
Merged

Separate Java version out of rbconfig 'arch'#9107
headius merged 1 commit intojruby:masterfrom
headius:no_arch_version

Conversation

@headius
Copy link
Member

@headius headius commented Dec 3, 2025

The 'arch' field in RbConfig::CONFIG is used by RubyGems to name a directory where the build artifacts from extension gems list. When a gem has been installed, but its extension does not appear in this directory, RubyGems knows the extension needs to be rebuilt and warns.

JRuby extensions are almost never platform-specific, so we have used a Java-related string for 'arch', with the current Java specification version appended like 'universal-java-21'. However because the version is included, any gems that have an extension build -- even if they don't actually build it on JRuby -- get associated with that exact 'arch' string. Switching to a different version of Java causes RubyGems to mistakenly think an extension needs to be built, and it warns.

See ruby/rubygems#3520 for related discussions.

The RubyGems team originally suggested ignoring the 'arch' version, since a similar situation affected CRuby on macOS (with an 'arch' of 'darwin-'), but ultimately they only ended up patching Bundler to ignore this version. Rather than try to further modify RubyGems to ignore this version component, JRuby will omit it in 'arch' and move it to a separate 'arch_version' field users can query if desired.

The 'arch' field in RbConfig::CONFIG is used by RubyGems to name a
directory where the build artifacts from extension gems list. When
a gem has been installed, but its extension does not appear in this
directory, RubyGems knows the extension needs to be rebuilt and
warns.

JRuby extensions are almost never platform-specific, so we have
used a Java-related string for 'arch', with the current Java
specification version appended like 'universal-java-21'. However
because the version is included, any gems that have an extension
build -- even if they don't actually build it on JRuby -- get
associated with that exact 'arch' string. Switching to a different
version of Java causes RubyGems to mistakenly think an extension
needs to be built, and it warns.

See ruby/rubygems#3520 for related
discussions.

The RubyGems team originally suggested ignoring the 'arch' version,
since a similar situation affected CRuby on macOS (with an 'arch'
of 'darwin-<version>'), but ultimately they only ended up patching
Bundler to ignore this version. Rather than try to further modify
RubyGems to ignore this version component, JRuby will omit it in
'arch' and move it to a separate 'arch_version' field users can
query if desired.
@eregon
Copy link
Member

eregon commented Dec 3, 2025

👍 this seems the right fix to me.

Regarding having the Java version available, I'm thinking having RbConfig::CONFIG['java_version'] would make sense (from system property java.version), for both JRuby and TruffleRuby.
java_specification_version seems also useful potentially (from property java.specification.version). It needs to be a String though because all values of RbConfig::CONFIG are strings and some programs rely on that (notably RVM).

In fact I almost added them in TruffleRuby in truffleruby/truffleruby#4025 but ended up declining that PR because the other versions don't yet have a good way to get them.
Also I guess if nobody needs them there is also no need to add them.

@headius
Copy link
Member Author

headius commented Dec 3, 2025

I would feel better about this change if CRuby did something similar to remove host platform versions from their 'arch' value as well, but I will merge this to head and see how the wider community reacts.

There's a fair justification for turning all of the 'java' prefixed properties into CONFIG values, but I think I would still keep the 'arch_version' to provide a common place where the host platform version can be acquired.

@headius
Copy link
Member Author

headius commented Dec 3, 2025

@eregon I'm on board with putting more "java" properties into CONFIG but it's not exactly relevant to this issue. Happy to discuss in a separate issue or PR.

Merging for 10.0.3.0.

@headius headius merged commit 846f601 into jruby:master Dec 3, 2025
76 of 77 checks passed
@headius headius deleted the no_arch_version branch December 3, 2025 17:57
@headius
Copy link
Member Author

headius commented Dec 3, 2025

Note there's a related issue for JRuby builds currently: the resolv-replace gem added in JRuby 10 (to support Ruby 3.4 standard gems) depends on the resolv gem, which means it needs to show up as a default gem. Since it is directly in our stdlib right now, RubyGems always warns about the missing extension.

I'm working to switch over our build to that gem in #9108.

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 this pull request may close these issues.

2 participants