postmodern / ruby-install

Installs Ruby, JRuby, TruffleRuby, or mruby
MIT License
1.9k stars 252 forks source link

ruby-install doesn't install JRuby properly, but ruby-build does #408

Closed todd-a-jacobs closed 2 years ago

todd-a-jacobs commented 2 years ago

Description

Running ruby-install jruby appears to work, but installs a version of jruby-9.2.19.0 that consistently reports a Java-related problem when calling chruby or irb, whether compiled under Fish or Bash:

~> chruby jruby
2021-09-20T16:46:33.174-04:00 [main] WARN FilenoUtil : Native subprocess control requires open access to the JDK IO subsystem
Pass '--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED' to enable.

Installing the same version of JRuby using ruby-build under Bash (not Fish) with the same user-configured build options results in a working JRuby that does not exhibit the error.

Steps To Reproduce

Steps to reproduce the bug:

  1. set -Ux RUBY_CONFIGURE_OPTS (printf -- '--with-openssl-dir="%s"' (brew --prefix openssl@1.1))
  2. ruby-install jruby
  3. Try again in Bash:
rm -rf .rubies/jruby-9.2.19.0/
~> bash

$ chruby system

$ echo $RUBY_CONFIGURE_OPTS 
--with-openssl-dir=/usr/local/opt/openssl@1.1

$ ruby-install jruby
>>> Installing jruby 9.2.19.0 into /Users/tjacobs/.rubies/jruby-9.2.19.0 ...
>>> Downloading https://repo1.maven.org/maven2/org/jruby/jruby-dist/9.2.19.0/jruby-dist-9.2.19.0-bin.tar.gz into /Users/$LOGNAME/src ...
>>> Verifying jruby-dist-9.2.19.0-bin.tar.gz ...
>>> Extracting jruby-dist-9.2.19.0-bin.tar.gz to /Users/tjacobs/src/jruby-9.2.19.0 ...
>>> Installing jruby 9.2.19.0 ...
>>> Symlinking bin/ruby to bin/jruby ...
>>> Successfully installed jruby 9.2.19.0 into /Users/tjacobs/.rubies/jruby-9.2.19.0

$ exec bash --login

 $ chruby jruby
2021-09-21T10:18:09.529-04:00 [main] WARN FilenoUtil : Native subprocess control requires open access to the JDK IO subsystem
Pass '--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED' to enable.
  1. Open new Terminal (or exec, or whatever you like to do, in order for chruby to pick up the new Ruby).
  2. chruby jruby
  3. Enjoy the error.
  4. irb
  5. Enjoy the error some more.
  6. Try again in Bash with ruby-build, and enjoy JRuby without the error using chruby:
$ ruby-build jruby-9.2.19.0 ~/.rubies/jruby-9.2.19.0
Downloading jruby-bin-9.2.19.0.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/1f74885a2d3fa589fcbeb292a39facf7f86be3eac1ab015e32c65d32acf3f3bf
Installing jruby-9.2.19.0...
tr: Illegal byte sequence
tr: Illegal byte sequence
Installed jruby-9.2.19.0 to /Users/$LOGNAME/.rubies/jruby-9.2.19.0

$ exec bash --login

$ chruby jruby

$ jruby --version
jruby 9.2.19.0 (2.5.8) 2021-06-15 55810c552b OpenJDK 64-Bit Server VM 16.0.2+0 on 16.0.2+0 +jit [darwin-x86_64]

$ irb
irb(main):001:0> 

Expected Behavior

JRuby should build and and run without significant errors, more or less. It should also result in a functional Ruby being installed. It should certainly not be less capable of compiling or linking JRuby, Rubinius, or TruffleRuby (which also have issues, but won't even compile) than ruby-build.

Actual Behavior

2021-09-21T09:55:35.488-04:00 [main] WARN FilenoUtil : Native subprocess control requires open access to the JDK IO subsystem Pass '--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED' to enable.

Environment

~> ruby-install --version
ruby-install: 0.8.2

~> uname -a
Darwin titan.local 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 x86_64

~> cc --version
Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

~> openssl --version
Invalid command '-h'; type "help" for a list.

~> openssl version
OpenSSL 1.1.1l  24 Aug 2021

~> env | fgrep RUBY
RUBY_CONFIGURE_OPTS=--with-openssl-dir=/usr/local/opt/openssl@1.1
RUBY_VERSION=3.0.2
RUBY_ROOT=/Users/$LOGNAME/.rubies/ruby-3.0.2
CHRUBY_VERSION=0.3.9
RUBY_AUTO_VERSION=3.0.2
RUBY_ENGINE=ruby
CHRUBY_FISH_VERSION=0.8.2

~> ruby-build --version
ruby-build 20210825
todd-a-jacobs commented 2 years ago

For the record, TruffleRuby and Rubinius won't even compile under ruby-install. While they are separate bugs, TruffleRuby installs fine under ruby-build as well, but I think JRuby is much important to fix, so I didn't file those detailed bugs yet. I'm happy to do so if desired.

postmodern commented 2 years ago

@todd-a-jacobs seeing as how I cannot reproduce this issue on Linux, this sounds like a macOS + Java issue. Can you reproduce the issue by installing JRuby manually without ruby-install? If so, then this is an upstream issue.

$ wget https://repo1.maven.org/maven2/org/jruby/jruby-dist/9.2.19.0/jruby-dist-9.2.19.0-bin.tar.gz
$ tar -xzvf jruby-dist-9.2.19.0-bin.tar.gz
$ cd jruby-9.2.19.0
$ ./bin/jruby -e "p 1 + 1"
2
postmodern commented 2 years ago

Appears related to Java 9:

postmodern commented 2 years ago

Same goes for TruffleRuby and Rubinius issues. If you cannot compile them manually without ruby-install, than that's an upstream or environment issue (likely related to the version of LLVM or Xcode).

todd-a-jacobs commented 2 years ago

This issue has gone away as of jruby-9.3.4.0 under macOS 11.6.5 and Homebrew 3.4.9-31-gb4f7dbc, so I'm gone to mark this as closed. It doesn't matter to me whether it was solved here, upstream, or in one of the build dependencies. It may also work in other configurations as well, but it certainly works with this one, so unless someone else is having issues I'm marking it resolved.