Last active
August 29, 2015 14:11
-
-
Save bbrowning/cda2606bd26683ea4831 to your computer and use it in GitHub Desktop.
RubyGems 2.4.5 triggers JRuby logic error when loading Java extensions from absolute paths
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bin/jruby -S gem install atomic | |
Fetching: atomic-1.1.16-java.gem (100%) | |
Successfully installed atomic-1.1.16-java | |
1 gem installed | |
$ bin/jruby ~/tmp/rubygems_java_ext_broken.rb | |
absolute paths are broken | |
relative paths work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Before running make sure to install the 'atomic' gem | |
# Load atomic_reference.jar using an absolute path, as RubyGems 2.4.5 | |
# sometimes does | |
gem "atomic" | |
atomic_lib = $LOAD_PATH.find { |p| p.include?("atomic") }; | |
jar_path = "#{atomic_lib}/atomic_reference.jar" | |
require jar_path | |
begin | |
Atomic | |
puts "absolute paths work" | |
rescue NameError => e | |
puts "absolute paths are broken" | |
end | |
# Now load the same jar using a relative path, as is typically done | |
require "atomic_reference" | |
begin | |
Atomic | |
puts "relative paths work" | |
rescue NameError => e | |
puts "relative paths are broken" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment