Skip to content

correct Win32API capitalization for JRuby - #484

Merged
hsbt merged 1 commit into
ruby:masterfrom
goatshriek:jruby-win32api-fix
Jan 4, 2023
Merged

hsbt merged 1 commit into
ruby:masterfrom
goatshriek:jruby-win32api-fix

Conversation

@goatshriek

@goatshriek goatshriek commented Dec 16, 2022 •

Copy link
Copy Markdown
Contributor

JRuby 9.4.0.0 seems to have introduced a change in case sensitivity in require statements, meaning that an inclusion of win32api that previously loaded Win32API.rb no longer works. With this change, the require statement needs to be updated to the correct capitalization of the filename to avoid reline failures in newer versions of JRuby.

This is intended to address #476. I haven't had a chance to test it myself for resolution of the JRuby problem, but will update this request once I have.

EDIT: clarify problem description and apparent cause

JRuby 9.4.0.0 introduced a change in case sensitivity in require statements,
meaning that an inclusion of `win32api` loaded Win32API.rb. With this change,
the require statement needs to be updated to the correct capitalization of the
filename to avoid reline failures in newer versions of JRuby.
@hsbt

hsbt commented Dec 16, 2022

Copy link
Copy Markdown
Member

Is it working with JRuby 9.3 or other versions? /cc @headius

@goatshriek

Copy link
Copy Markdown
Contributor Author

JRuby 9.3 versions seem to work fine on my system with no changes; I included some output from 9.3.9.0 working in the linked issue.

@goatshriek

Copy link
Copy Markdown
Contributor Author

I was able to build JRuby from the source and make this tweak to reline before building a JRuby complete jar. This did indeed resolve the issue described in #476, allowing an irb session to open. Unfortunately, it does suffer from the issue described in #477, but I don't believe this is related to the change.

I did download the 9.3.9.0 source and try to build it with the tweak as well, but I didn't find reline in the build. Perhaps it is a new addition in 9.4.0.0?

@sfrieske

sfrieske commented Jan 3, 2023

Copy link
Copy Markdown

It hasn't been working for quite a long while. JRUBY 9.3.8 (jruby-jar) still requires a change in lib/reline/windows.rb line #56.

@hsbt
hsbt merged commit 2a3ac10 into ruby:master Jan 4, 2023
@hsbt

hsbt commented Jan 4, 2023

Copy link
Copy Markdown
Member

I merged this. But I also wondered why JRuby need win32api. It's already deprecated https://github.com/ruby/win32api/blob/master/lib/Win32API.rb#L5

@goatshriek
goatshriek deleted the jruby-win32api-fix branch January 4, 2023 10:51
@headius

headius commented Jan 4, 2023

Copy link
Copy Markdown
Contributor

Finally jumping into this one...

It appears that the .rb file has been Win32API.rb (with caps) forever, so that is not a recent change. More likely is that something changed in file loading that made it case-sensitive. That would be a bug in JRuby, and it should be easy to reproduce it and file an issue (please do!).

Long term, however, we would ideally be able to move away from this special code. Perhaps the non-JRuby logic might work fine on JRuby, or perhaps require only some small changes?

I do not have a Windows machine to test on at the moment.

@hsbt

hsbt commented Jan 4, 2023

Copy link
Copy Markdown
Member

@headius Thanks to your comment.

https://github.com/ruby/reline/pull/484/files#diff-f91a9b95540b46598f1f9933da9aa6899df9b4c113b26e02460ab487db4cdd32R58 is copy-and-paste logic of Win32API.rb. We can remove JRuby condition or rewrite this.

@headius

headius commented Jan 4, 2023

Copy link
Copy Markdown
Contributor

@hsbt The main issue is that JRuby's Win32API uses FFI rather than Fiddle. I'm not sure if the Fiddle logic will work with our current, somewhat broken Fiddle implementation. I'm not sure the best way to proceed, but releasing with this temporary patch is probably ok for now.

@hsbt

hsbt commented Jan 5, 2023

Copy link
Copy Markdown
Member

@hsbt The main issue is that JRuby's Win32API uses FFI rather than Fiddle

oh, I see.

@enebo

enebo commented Jan 23, 2023

Copy link
Copy Markdown

We corrected the naming of this on JRuby to win32api.rb. Either solution would work but jruby-complete.jar (all-in-one ruby distro) on windows is a case-sensitive search and I feel that the normal convention of files for require are all lower case. For ordinary JRuby installations require "win32api" will match any case on Windows since windows still uses case-insensitive file system.

So I recommend not applying this PR since we already changed it in JRuby 9.3 and JRuby 9.4 (next releases will see this).

@hsbt

hsbt commented Jan 24, 2023

Copy link
Copy Markdown
Member

oh. @enebo /cc @headius Should we revert this?

@headius

headius commented Jan 24, 2023

Copy link
Copy Markdown
Contributor

@hsbt Perhaps so? It won't work in current versions but upcoming versions will have the renamed file.

@enebo

enebo commented Jan 25, 2023

Copy link
Copy Markdown

@hsbt yes please.

@ima1zumi ima1zumi added bug Something isn't working and removed bug Something isn't working labels Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants