Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Missing 4.0.3 for JRuby #52

Closed
headius opened this issue Jan 4, 2024 · 12 comments
Closed

Missing 4.0.3 for JRuby #52

headius opened this issue Jan 4, 2024 · 12 comments
Assignees

Comments

@headius
Copy link

headius commented Jan 4, 2024

Seems like it wasn't pushed. As a result the 4.0.3 gem cannot install on JRuby because it depends on C extensions.

https://rubygems.org/gems/erb/versions

@k0kubun
Copy link
Member

k0kubun commented Jan 4, 2024

Ugh, I'm sorry. I just pushed it.

It's such a pain to make a separate release for JRuby, and I've heard a way to somehow support both despite having a C extension before. I'm gonna look into it.

@k0kubun k0kubun closed this as completed Jan 4, 2024
@k0kubun
Copy link
Member

k0kubun commented Jan 4, 2024

@k0kubun
Copy link
Member

k0kubun commented Jan 4, 2024

So I just pushed 4.0.4, and I deliberately did NOT push a -java gem. It seems to work fine.

$ RUBYOPT=-v gem install erb -v 4.0.4
jruby 9.4.3.0 (3.1.4) 2023-06-07 3086960792 OpenJDK 64-Bit Server VM 25.392-b08 on 1.8.0_392-8u392-ga-1~22.04-b08 +jit [x86_64-linux]
Fetching erb-4.0.4.gem
Building native extensions. This could take a while...
Successfully installed erb-4.0.4
1 gem installed

@headius
Copy link
Author

headius commented Jan 4, 2024

@k0kubun It does install, but on systems where make is not available, it will still fail on JRuby, despite not building any extension. Unfortunately there's no way to tell RubyGems to ignore the ext on JRuby... it will always try to build something.

The best way to fix this would be to move the extension to a separate gem erb-escape that can be shipped with CRuby but optional for all users. See #32 which was never really resolved.

We could also port the extension to JRuby, but that would still require a -java gem to avoid the makefile/build logic.

@headius
Copy link
Author

headius commented Jan 4, 2024

And thank you for pushing updates! I believe we'll still need a 4.0.4-java that does not try to generate a makefile and run it.

@k0kubun
Copy link
Member

k0kubun commented Jan 4, 2024

Unfortunately there's no way to tell RubyGems to ignore the ext on JRuby... it will always try to build something.

This seems like the actual problem to me. Can we add an API in extconf to skip executing make? To me, that would be the best fix. Adding yet another default gem seems too much of a hassle just for supporting systems without make. Also, considering @byroot is already doing it at redis-client.gem, JRuby & Redis users would already have make. It's not new.

In the meantime, I pushed 4.0.4-java. Until the actual problem is fixed, however, I might still forget to run rake release twice in future versions.

@k0kubun
Copy link
Member

k0kubun commented Jan 5, 2024

hsbt shared that nobu implemented a rake task to build a java gem from CRuby https://github.com/ruby/io-console/blob/v0.7.0/rakelib/build_java.rake. If running rake release on this repository automatically publishes both CRuby and JRuby gems, I'd be okay with that too.

@byroot
Copy link
Member

byroot commented Jan 5, 2024

https://bugs.ruby-lang.org/issues/20152

@eregon
Copy link
Member

eregon commented Jan 6, 2024

File.write("Makefile", dummy_makefile($srcdir).join("")) is the way to go 👍

I replied in https://bugs.ruby-lang.org/issues/20152?next_issue_id=20151&prev_issue_id=20153#note-7.
I think trying to avoid needing make is very niche, and it can be done via multi-stage Docker file.
It cannot be avoided e.g. for sassc and prism and other gems using FFI which need to build the C code using make.
(and make is not big to start with, it's not like we are requiring a full C toolchain)

@eregon
Copy link
Member

eregon commented Jan 6, 2024

Unfortunately there's no way to tell RubyGems to ignore the ext on JRuby...

RubyGems could detect dummy Makefiles as those created by File.write("Makefile", dummy_makefile($srcdir).join("")) and if so not call make.
Maybe JRuby could experiment with this since it's the main use case?
On CRuby/TruffleRuby it's not relevant as one needs make and a C toolchain to install gems with native (not-precompiled) extensions (like erb).

@headius
Copy link
Author

headius commented Jan 24, 2024

@k0kubun:

If running rake release on this repository automatically publishes both CRuby and JRuby gems, I'd be okay with that too.

That would be great! I sympathize with the extra support required, but we are standing by to help at any time. Until RubyGems is more flexible about install-time dependencies and dummy extension builds, this is the simplest answer.

@eregon:

I think trying to avoid needing make is very niche, and it can be done via multi-stage Docker file.

Windows.

Seriously though, hardly any JRuby dependencies require C build tools and we want to keep it that way as much as possible. JRuby users should be able to get up and running on any system with just a Java installation present.

It cannot be avoided e.g. for sassc and prism

It can be avoided for sassc by downloading a pre-built library. That doesn't happen on the JRuby version yet, but it could (just needs some work on the platform-agnostic version of the gem).

It can be avoided for prism the same way, by downloading a pre-built native binary. We are also exploring options to run prism directly on JVM without native code.

In any case, two examples that actually do need to be built to run does nothing to validate a Makefile that does nothing. It does not make sense to me to generate a dummy Makefile and require make when they will produce nothing at all.

And I can see a future where TruffleRuby might want this feature as well: you might run erb's Ruby code faster than the extension, and want to opt-out of building and using it. The dummy Makefile would accomplish that, but being able to say "no extension on TruffleRuby please" would be much cleaner.

RubyGems could detect dummy Makefiles

This would be much better. Nothing will happen for an empty Makefile in either case, so there's little point in running make.

headius added a commit to jruby/jruby that referenced this issue Jan 24, 2024
This version provides a -java gem that does not try to build an
extension. We are discussing how to make this simpler and contain
it within one gem.

See ruby/erb#52 and the CRuby issue at
https://bugs.ruby-lang.org/issues/20152?next_issue_id=20151&prev_issue_id=20153#note-7
@eregon
Copy link
Member

eregon commented Jan 24, 2024

It can be avoided for prism the same way, by downloading a pre-built native binary.

But this would require prism to build & publish prebuilt binaries, that is a lot of trouble and extra complications.

This would be much better. Nothing will happen for an empty Makefile in either case, so there's little point in running make.

Yes I think this is the best way to address this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants