jruby / docker-jruby

MIT License
18 stars 27 forks source link

No `javac` in image (yes, use `-jdk` images) #87

Closed dentarg closed 1 month ago

dentarg commented 1 month ago

Sorry about this issue, but I have a hard time seeing what goes wrong and why this isn't just working. I have JRuby 9.4.8.0 installed with ruby-build in macOS and have no problem running the Puma specs there.

Here's what happens when I clone the Puma repo fresh and tries the lastest Docker image (I see the same thing in 9.4.5.0 and 9.3.15.0).

It is bundle exec rake --trace compile that is the problem:

$ git clone git@github.com:puma/puma.git puma
...

$ docker pull jruby:9.4.8.0
9.4.8.0: Pulling from library/jruby
Digest: sha256:f9bb19f10d8239c04101fae5bfebf45f6bc756b61ad8be659bbfd2d0acfc5330
Status: Image is up to date for jruby:9.4.8.0
docker.io/library/jruby:9.4.8.0

$ docker run -it --rm -v $(pwd):/app -w /app jruby:9.4.8.0 bash
root@01c002618cc9:/app# apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends ragel git
...

root@01c002618cc9:/app# bundle install
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Fetching json 2.7.2 (java)
Fetching language_server-protocol 3.17.0.3
Fetching ast 2.4.2
Fetching jruby-openssl 0.15.0 (java)
Installing language_server-protocol 3.17.0.3
Installing ast 2.4.2
Installing json 2.7.2 (java)
Fetching localhost 1.3.1
Installing localhost 1.3.1
Fetching method_source 1.1.0
Fetching minitest 5.25.1
Installing method_source 1.1.0
Installing minitest 5.25.1
Fetching minitest-stub-const 0.6
Installing minitest-stub-const 0.6
Fetching nio4r 2.7.3 (java)
Fetching parallel 1.26.3
Installing parallel 1.26.3
Installing nio4r 2.7.3 (java)
Fetching racc 1.8.1 (java)
Installing jruby-openssl 0.15.0 (java)
Installing racc 1.8.1 (java)
Fetching rack 3.1.7
Fetching rainbow 3.1.1
Installing rainbow 3.1.1
Installing rack 3.1.7
Fetching rake-compiler 1.1.9
Fetching regexp_parser 2.9.2
Installing regexp_parser 2.9.2
Installing rake-compiler 1.1.9
Fetching ruby-progressbar 1.13.0
Installing ruby-progressbar 1.13.0
Fetching m 1.6.2
Fetching unicode-display_width 2.6.0
Installing unicode-display_width 2.6.0
Fetching minitest-proveit 1.0.0
Installing m 1.6.2
Fetching minitest-retry 0.2.3
Installing minitest-proveit 1.0.0
Installing minitest-retry 0.2.3
Fetching rackup 2.1.0
Fetching parser 3.3.5.0
Installing rackup 2.1.0
Installing parser 3.3.5.0
Fetching rubocop-ast 1.32.3
Installing rubocop-ast 1.32.3
Fetching rubocop 1.66.1
Installing rubocop 1.66.1
Fetching rubocop-performance 1.22.1
Installing rubocop-performance 1.22.1
Bundle complete! 15 Gemfile dependencies, 29 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
1 installed gem you directly depend on is looking for funding.
  Run `bundle fund` for details

root@01c002618cc9:/app# bundle exec rake --trace compile
** Invoke compile (first_time)
** Invoke compile:java (first_time)
** Invoke compile:puma_http11:java (first_time)
** Invoke copy:puma_http11:java (first_time)
** Invoke lib/puma (first_time, not_needed)
** Invoke tmp/java/puma_http11/puma_http11.jar (first_time)
** Invoke tmp/java/puma_http11/.build (first_time)
** Invoke tmp/java/puma_http11 (first_time, not_needed)
** Invoke ext/puma_http11/PumaHttp11Service.java (first_time, not_needed)
** Invoke ext/puma_http11/org/jruby/puma/Http11.java (first_time, not_needed)
** Invoke ext/puma_http11/org/jruby/puma/Http11Parser.java (first_time, not_needed)
** Invoke ext/puma_http11/http11_parser.java.rl (first_time, not_needed)
** Invoke ext/puma_http11/org/jruby/puma/MiniSSL.java (first_time, not_needed)
** Execute tmp/java/puma_http11/.build
rake aborted!
Command failed with status (127): [javac --release=8 -Xlint -d tmp/java/puma_http11 -extdirs /opt/java/openjdk/lib/ext:/usr/java/packages/lib/ext -cp /opt/java/openjdk/lib/resources.jar:/opt/java/openjdk/lib/rt.jar:/opt/java/openjdk/lib/sunrsasign.jar:/opt/java/openjdk/lib/jsse.jar:/opt/java/openjdk/lib/jce.jar:/opt/java/openjdk/lib/charsets.jar:/opt/java/openjdk/lib/jfr.jar:/opt/java/openjdk/classes:/opt/jruby/lib/jruby.jar ext/puma_http11/PumaHttp11Service.java ext/puma_http11/org/jruby/puma/Http11.java ext/puma_http11/org/jruby/puma/Http11Parser.java ext/puma_http11/org/jruby/puma/MiniSSL.java]
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/file_utils.rb:64:in `block in create_shell_runner'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/file_utils.rb:57:in `sh'
/usr/local/bundle/gems/rake-compiler-1.1.9/lib/rake/javaextensiontask.rb:122:in `block in define_compile_tasks'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:281:in `block in execute'
org/jruby/RubyArray.java:1981:in `each'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:281:in `execute'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
org/jruby/ext/monitor/Monitor.java:82:in `synchronize'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:243:in `block in invoke_prerequisites'
org/jruby/RubyArray.java:1981:in `each'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:241:in `invoke_prerequisites'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
org/jruby/ext/monitor/Monitor.java:82:in `synchronize'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:243:in `block in invoke_prerequisites'
org/jruby/RubyArray.java:1981:in `each'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:241:in `invoke_prerequisites'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
org/jruby/ext/monitor/Monitor.java:82:in `synchronize'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:243:in `block in invoke_prerequisites'
org/jruby/RubyArray.java:1981:in `each'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:241:in `invoke_prerequisites'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
org/jruby/ext/monitor/Monitor.java:82:in `synchronize'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:243:in `block in invoke_prerequisites'
org/jruby/RubyArray.java:1981:in `each'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:241:in `invoke_prerequisites'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
org/jruby/ext/monitor/Monitor.java:82:in `synchronize'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:243:in `block in invoke_prerequisites'
org/jruby/RubyArray.java:1981:in `each'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:241:in `invoke_prerequisites'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
org/jruby/ext/monitor/Monitor.java:82:in `synchronize'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/task.rb:188:in `invoke'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/application.rb:188:in `invoke_task'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/application.rb:138:in `block in top_level'
org/jruby/RubyArray.java:1981:in `each'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/application.rb:138:in `block in top_level'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/application.rb:147:in `run_with_threads'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/application.rb:132:in `top_level'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/application.rb:83:in `block in run'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/application.rb:214:in `standard_exception_handling'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/lib/rake/application.rb:80:in `run'
/opt/jruby/lib/ruby/gems/shared/gems/rake-13.2.1/exe/rake:27:in `<main>'
org/jruby/RubyKernel.java:1220:in `load'
/opt/jruby/bin/rake:25:in `<main>'
org/jruby/RubyKernel.java:1220:in `load'
/opt/jruby/lib/ruby/gems/shared/gems/bundler-2.5.17/lib/bundler/cli/exec.rb:58:in `kernel_load'
/opt/jruby/lib/ruby/gems/shared/gems/bundler-2.5.17/lib/bundler/cli/exec.rb:23:in `run'
/opt/jruby/lib/ruby/gems/shared/gems/bundler-2.5.17/lib/bundler/cli.rb:455:in `exec'
/opt/jruby/lib/ruby/gems/shared/gems/bundler-2.5.17/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
/opt/jruby/lib/ruby/gems/shared/gems/bundler-2.5.17/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/opt/jruby/lib/ruby/gems/shared/gems/bundler-2.5.17/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
/opt/jruby/lib/ruby/gems/shared/gems/bundler-2.5.17/lib/bundler/cli.rb:35:in `dispatch'
/opt/jruby/lib/ruby/gems/shared/gems/bundler-2.5.17/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
/opt/jruby/lib/ruby/gems/shared/gems/bundler-2.5.17/lib/bundler/cli.rb:29:in `start'
/opt/jruby/lib/ruby/gems/shared/gems/bundler-2.5.17/exe/bundle:28:in `block in <main>'
/opt/jruby/lib/ruby/gems/shared/gems/bundler-2.5.17/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/opt/jruby/lib/ruby/gems/shared/gems/bundler-2.5.17/exe/bundle:20:in `<main>'
org/jruby/RubyKernel.java:1220:in `load'
/opt/jruby/bin/bundle:25:in `<main>'
Tasks: TOP => compile => compile:java => compile:puma_http11:java => copy:puma_http11:java => tmp/java/puma_http11/puma_http11.jar => tmp/java/puma_http11/.build
dentarg commented 1 month ago

Oh, the problem is that the Docker image has no javac šŸ˜®

root@01c002618cc9:/app# javac
bash: javac: command not found
dentarg commented 1 month ago

A bit similar to https://github.com/jruby/jruby/issues/8062 ... but maybe something that one could expect?

dentarg commented 1 month ago

Ah, the -jdk images have javac

dentarg commented 1 month ago

Using jruby:9.4.8.0-jdk it still didn't work

root@0d5774b3f421:/app# bundle exec rake --trace compile
** Invoke compile (first_time)
** Invoke compile:java (first_time)
** Invoke compile:puma_http11:java (first_time)
** Invoke copy:puma_http11:java (first_time)
** Invoke lib/puma (first_time, not_needed)
** Invoke tmp/java/puma_http11/puma_http11.jar (first_time)
** Invoke tmp/java/puma_http11/.build (first_time)
** Invoke tmp/java/puma_http11 (first_time, not_needed)
** Invoke ext/puma_http11/PumaHttp11Service.java (first_time, not_needed)
** Invoke ext/puma_http11/org/jruby/puma/Http11.java (first_time, not_needed)
** Invoke ext/puma_http11/org/jruby/puma/Http11Parser.java (first_time, not_needed)
** Invoke ext/puma_http11/http11_parser.java.rl (first_time, not_needed)
** Invoke ext/puma_http11/org/jruby/puma/MiniSSL.java (first_time, not_needed)
** Execute tmp/java/puma_http11/.build
javac: invalid flag: --release=8
Usage: javac <options> <source files>
use -help for a list of possible options
rake aborted!
Command failed with status (2): [javac --release=8 -Xlint -d tmp/java/puma_http11 -extdirs /opt/java/openjdk/jre/lib/ext:/usr/java/packages/lib/ext -cp /opt/java/openjdk/jre/lib/resources.jar:/opt/java/openjdk/jre/lib/rt.jar:/opt/java/openjdk/jre/lib/sunrsasign.jar:/opt/java/openjdk/jre/lib/jsse.jar:/opt/java/openjdk/jre/lib/jce.jar:/opt/java/openjdk/jre/lib/charsets.jar:/opt/java/openjdk/jre/lib/jfr.jar:/opt/java/openjdk/jre/classes:/opt/jruby/lib/jruby.jar ext/puma_http11/PumaHttp11Service.java ext/puma_http11/org/jruby/puma/Http11.java ext/puma_http11/org/jruby/puma/Http11Parser.java ext/puma_http11/org/jruby/puma/MiniSSL.java]
...

Maybe a Puma problem? but everything is fine in CI over there (and macOS for me...)

Oh I see warnings in macOS

warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
dentarg commented 1 month ago

I will create an issue on Puma for this. Sorry for the noise.

dentarg commented 1 month ago

OK, using the latest rake-compiler (1.2.7) gem solves it for jruby:9.4.8.0-jdk. Puma repo was locked to 1.1.9.

headius commented 1 month ago

Ok thanks for the extra footwork! Nothing else to do on our end, correct?

dentarg commented 1 month ago

Correct! Sorry again for the noise. Hopefully this issue helps someone else in the future in regards to jre vs jdk images :)