Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Cannot install versions 8.7+ on JRuby due to zlib dependency #308

Open
nc-thomaez opened this issue Feb 7, 2025 · 1 comment
Open

Cannot install versions 8.7+ on JRuby due to zlib dependency #308

nc-thomaez opened this issue Feb 7, 2025 · 1 comment

Comments

@nc-thomaez
Copy link

Describe the bug
When we try to install recent versions of launchdarkly-server-sdk on JRuby, the gem installation fails when it tries to compile native extensions for the zlib gem. #291 added support for event payload compression with zlib and attempted to exclude the zlib dependency for JRuby, but we don't believe this is working as expected.

To reproduce
First, create the following Gemfile in a new JRuby 9.4 project:

source "https://rubygems.org"

gem "launchdarkly-server-sdk", "~> 8"

Next, run bundle install.

Expected behavior
launchdarkly-server-sdk version 8.x (8.8.2 as of this writing) is installed with no errors.

Logs
The full output from running bundle install on a fresh project:

~/c/s/launchdarkly-jruby-reproduction ❱ ruby --version
jruby 9.4.11.0 (3.1.4) 2025-01-29 9b107851a3 OpenJDK 64-Bit Server VM 25.372-b07 on 1.8.0_372-b07 +jit [x86_64-darwin]
~/c/s/launchdarkly-jruby-reproduction ❱ bundle
Fetching gem metadata from https://rubygems.org/........
Resolving dependencies...
Fetching rake 13.2.1
Installing rake 13.2.1
Fetching http-form_data 2.3.0
Fetching base64 0.2.0
Fetching observer 0.1.2
Fetching public_suffix 6.0.1
Fetching json 2.9.1 (java)
Fetching concurrent-ruby 1.3.5
Fetching semantic 1.6.1
Fetching domain_name 0.6.20240107
Fetching zlib 3.2.1
Fetching ffi 1.17.1 (java)
Installing observer 0.1.2
Installing json 2.9.1 (java)
Installing semantic 1.6.1
Installing domain_name 0.6.20240107
Installing base64 0.2.0
Installing public_suffix 6.0.1
Installing ffi 1.17.1 (java)
Installing http-form_data 2.3.0
Installing zlib 3.2.1 with native extensions
Installing concurrent-ruby 1.3.5
Fetching addressable 2.8.7
Fetching http-cookie 1.0.8
Installing addressable 2.8.7
Installing http-cookie 1.0.8
Fetching ffi-compiler 1.3.2
Installing ffi-compiler 1.3.2
Fetching llhttp-ffi 0.5.0
Installing llhttp-ffi 0.5.0 with native extensions
Fetching http 5.2.0
Installing http 5.2.0
Fetching ld-eventsource 2.2.2
Installing ld-eventsource 2.2.2
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/gems/shared/gems/zlib-3.2.1/ext/zlib
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/bin/jruby extconf.rb
checking for deflateReset(NULL) in -lz... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/bin/jruby
	--with-zlib-dir
	--without-zlib-dir
	--with-zlib-include
	--without-zlib-include=${zlib-dir}/include
	--with-zlib-lib
	--without-zlib-lib=${zlib-dir}/lib
	--with-zlib
	--without-zlib
RuntimeError: The compiler failed to generate an executable file.
You have to install development tools first.

try_do at
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/mkmf.rb:456
try_link0 at
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/mkmf.rb:541
try_link at
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/mkmf.rb:556
try_func at
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/mkmf.rb:765
have_library at
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/mkmf.rb:997
checking_for at
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/mkmf.rb:942
postpone at
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/mkmf.rb:350
open at
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/mkmf.rb:320
postpone at
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/mkmf.rb:350
open at
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/mkmf.rb:320
postpone at
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/mkmf.rb:346
checking_for at
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/mkmf.rb:941
have_library at
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/mkmf.rb:992
        <main> at extconf.rb:14
          any? at org/jruby/RubyArray.java:4980
        <main> at extconf.rb:14

To see why this extension failed to compile, please check the mkmf.log which can
be found here:

/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/gems/shared/extensions/universal-java-1.8/3.1.0/zlib-3.2.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/gems/shared/gems/zlib-3.2.1
  2 source "https://rubygems.org"
for inspection.
Results logged to
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/gems/shared/extensions/universal-java-1.8/3.1.0/zlib-3.2.1/gem_make.out

/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/rubygems/ext/builder.rb:126:in
`run'
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/rubygems/ext/ext_conf_builder.rb:30:in
`build'
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/rubygems/ext/builder.rb:195:in
`build_extension'
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/rubygems/ext/builder.rb:229:in
`block in build_extensions'
  org/jruby/RubyArray.java:2009:in `each'
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/rubygems/ext/builder.rb:226:in
`build_extensions'
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/rubygems/installer.rb:844:in
`build_extensions'
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/bundler/rubygems_gem_installer.rb:111:in
`build_extensions'
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/bundler/rubygems_gem_installer.rb:30:in
`install'
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/bundler/source/rubygems.rb:205:in
`install'
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/bundler/installer/gem_installer.rb:55:in
`install'
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/bundler/installer/gem_installer.rb:17:in
`install_from_spec'
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/bundler/installer/parallel_installer.rb:133:in
`do_install'
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/bundler/installer/parallel_installer.rb:124:in
`block in worker_pool'
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/bundler/worker.rb:62:in
`apply_func'
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/bundler/worker.rb:57:in
`block in process_queue'
  org/jruby/RubyKernel.java:1725:in `loop'
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/bundler/worker.rb:54:in
`process_queue'
/Users/thomaez/.rbenv/versions/jruby-9.4.11.0/lib/ruby/stdlib/bundler/worker.rb:90:in
`block in create_threads'

An error occurred while installing zlib (3.2.1), and Bundler cannot
continue.

In Gemfile:
  launchdarkly-server-sdk was resolved to 8.8.2, which depends on
    zlib

SDK version
We're experiencing this with SDK versions 8.8.2 and 8.7.1.

Language version, developer tools
We've reproduced this on the following JRuby versions:

  • 9.4.11.0 (the latest as of this writing)
  • 9.4.2.0

OS/platform
We've reproduced this on the following platforms

  • MacOS version 15.2
  • The ubuntu-latest GitHub Actions runner (based on Ubuntu 24.04 as of this writing)

Additional context
@nc-srstkac has done some digging and believes he found the problem. If you download the .gem file from rubygems.org, expand it with tar xf, and extract the gem metadata with gunzip metadata.gz, you'll see that it includes zlib:

- !ruby/object:Gem::Dependency
  name: zlib
  requirement: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '3.1'
  type: :runtime
  prerelease: false
  version_requirements: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '3.1'

Our suspicion is that the RUBY_PLATFORM condition in the gemspec file doesn't do what it's supposed to. We believe that, rather than acting like a runtime platform check that will exclude zlib as a dependency when the gem is being installed on JRuby, the check is only being evaluated when the gem is being built for publishing. This likely means you'll need to publish an alternate version of the gem for the JRuby platform that has the platform check evaluated in the right way. I believe this is similar to what Nokogiri does -- they have a similar RUBY_PLATFORM check in their gemspec file, but they also have a separately-published -java version series.

@keelerm84
Copy link
Member

Thank you for bringing this to our attention. We will work to get this resolved as soon as we are able. I will let you know here once we have this fixed!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants