jeremyevans / sequel

Sequel: The Database Toolkit for Ruby
http://sequel.jeremyevans.net
Other
4.99k stars 1.07k forks source link

bigdecimal dependency breaks installation on JRuby #2076

Closed headius closed 1 year ago

headius commented 1 year ago

Complete Description of Issue

Version 5.72.0 added a gem dependency on bigdecimal. There's no bigdecimal gem for JRuby, currently, so this prevents sequel from installing.

Reported to JRuby as https://github.com/rubygems/gemstash/issues/358

I don't believe there's anything to fix on the sequel end but I am opening this bug to track the issue. I believe the correct fix would be to get the bigdecimal gem to release a stub -java version, so dependencies on bigdecimal will not prevent installation.

This was also originally reported to the bigdecimal gem in https://github.com/ruby/bigdecimal/issues/169 and fixed in https://github.com/ruby/bigdecimal/pull/250 but no -java gem has been released for bigdecimal yet.

cc @hsbt and @mrkn

Simplest Possible Self-Contained Example Showing the Bug

Just try to install latest sequel on JRuby. It will depend on bigdecimal, and try to build the CRuby extension.

Full Backtrace of Exception (if any)

No response

SQL Log (if any)

No response

Ruby Version

No response

Sequel Version

5.72.0

hsbt commented 1 year ago

@headius Should we release java version of bigdecimal-3.1.4?

jeremyevans commented 1 year ago

@headius Thanks for the heads up. If it is possible to release a java version of bigdecimal quickly, that seems like the best approach. If not, I can push out a new version of Sequel that drops the bigdecimal dependency, but this definitely would need to be addressed before the release of Ruby 3.3.

headius commented 1 year ago

@hsbt that would be great! The work was all completed in February so I think we just need to get the stub gems released. See the linked issue and PR.

headius commented 1 year ago

@jeremyevans Why 3.3 particularly?

jeremyevans commented 1 year ago

@headius If you are using bundler, CRuby 3.3 will start warning if you require 'bigdecimal' without bigdecimal being in the Gemfile. This will turn into an error in CRuby 3.4. This is the reason that Sequel started requiring bigdecimal, so that applications created with Sequel 5.72 will not start warning in CRuby 3.3 or failing in CRuby 3.4.

headius commented 1 year ago

@jeremyevans Ahh, so bigdecimal is finally getting unbundled?

I was just concerned there was some new feature you started using, but this seems reasonable. Hopefully I can work with @hsbt and @mrkn to get the -java stub versions released soon.

jeremyevans commented 1 year ago

You could say it is getting bundled, since it is moving from a default gem to a bundled gem :)

There are no features in BigDecimal used by Sequel, Sequel still works with Ruby 1.9's BigDecimal library.

If the bigdecimal java gem is going to take more than a few days, please let me know and I can put out a new version of Sequel without the dependency. Sorry I didn't test this earlier, I guess I assumed that if bigdecimal was a standard gem on CRuby, it was also a standard gem on JRuby, but that is apparently not true. Wasn't caught by CI because CI doesn't use the gemspec (due to problems with using it and supporting versions of bundler back to Ruby 1.9). I should have added it to .ci.gemfile, that would have caught the issue before the release.

headius commented 1 year ago

Unfortunately bigdecimal is a very large C extension, and since the JDK provides a built-in BigDecimal implementation it made more sense for us to just ship our thin wrapper around that API. We have considered moving that wrapper into the gem, but @mrkn has had concerns about maintaining that code or having CI failures when only the C code gets updated.

It's an unfortunate fact of Ruby gems that there's no way to publish a separate library that will be seen as equivalent, so our only choice is to work with gem authors to publish -java versions either with Java code or as a stub.

jeremyevans commented 1 year ago

For CRuby default gems, they remain in the standard library, but CRuby ships with a gemspec for them. You cannot uninstall them, but they still show up in gem list. You can install newer versions of the gems, and use the gem method to pick a specific version (as long as the standard library version has not already been loaded). Not sure if JRuby wants to take that approach or not. Having bigdecimal as a default gem in JRuby would fix this, but since JRuby doesn't already have it, it would only fix it going forward. Since Sequel wants to support already released versions of JRuby, it looks like a bigdecimal java gem release is the only long term solution, because CRuby is moving bigdecimal from a default gem to a bundled gem.

hsbt commented 1 year ago

@headius I've published Java version of bigdecimal at https://rubygems.org/gems/bigdecimal/versions/3.1.4-java

jeremyevans commented 1 year ago

@hsbt Thanks, that fixes the issue!:

$ jruby -S gem install sequel
Fetching bigdecimal-3.1.4-java.gem
Fetching sequel-5.72.0.gem
Successfully installed bigdecimal-3.1.4-java
Successfully installed sequel-5.72.0
Parsing documentation for bigdecimal-3.1.4-java
Installing ri documentation for bigdecimal-3.1.4-java
Parsing documentation for sequel-5.72.0
Installing ri documentation for sequel-5.72.0
Done installing documentation for bigdecimal, sequel after 45 seconds
2 gems installed
headius commented 1 year ago

@hsbt Thank you, that's great! I will update JRuby 9.4 to also source files from the gem.