Skip to content

Commit 98b0108

Browse files
committed
Force build-time gem installs to use current JRuby config
The RubyGems we run at build time runs with JRuby 9.4, which causes it to use properties from that version for things like gem paths and extension directories. This is related to the extension disabling change in jruby#8415 and causes the build-time extension faking to use the wrong path. For example: .../gems/shared/extensions/universal-java-25/3.1.0 when it should be .../gems/shared/extensions/universal-java/3.4.0 The change here uses RubyGems' cross-compiling capability by forcing a specific rbconfig.rb to be use, and additionally fakes out the Ruby API version by setting @ruby_api_version on the Gem module. This was discovered while attempting to switch fully to the syslog gem in jruby#9109, since as a bundled gem it will not be activated unless we successfully fake-out the extension build. See also this bug related to the resolv gem installing extensions: * jruby#8649
1 parent 20cf138 commit 98b0108

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ failures
2929
.debug.properties
3030
.redcar
3131
/.rbx/
32-
build
3332
build.properties
3433
build_graph.png
3534
core/src/main/java/org/jruby/runtime/Constants.java

lib/pom.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ def log(message = nil)
213213

214214
log "using jruby #{JRUBY_VERSION}"
215215

216+
# force platform to match build JRuby
217+
Gem.set_target_rbconfig(File.join(File.dirname(__FILE__), "ruby/stdlib/jruby/build/rbconfig.rb"))
218+
Gem.instance_variable_set :@ruby_api_version, Gem.target_rbconfig['ruby_version']
219+
216220
target = ctx.project.build.directory.to_pathname
217221
gem_home = File.join(target, 'rubygems')
218222
gems = File.join(gem_home, 'gems')
@@ -251,6 +255,7 @@ def build_extensions
251255
say 'Skipping native extensions.'
252256

253257
FileUtils.mkdir_p File.dirname(@spec.gem_build_complete_path)
258+
p @spec.gem_build_complete_path
254259
FileUtils.touch @spec.gem_build_complete_path
255260
end
256261
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This file is used by JRuby's build to override the RubyGems platform
2+
3+
module RbConfig
4+
build_props = {}
5+
File.open(File.join(__FILE__, "../../../../../../default.build.properties")) do |file|
6+
build_props = java.util.Properties.new
7+
build_props.load(file.to_input_stream)
8+
end
9+
10+
CONFIG = {}
11+
CONFIG['ruby_version'] = build_props["version.ruby.major"] + '.0'
12+
CONFIG['arch'] = 'universal-java'
13+
end

0 commit comments

Comments
 (0)