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

Provide ruby.exe so it's a drop-in replacement for MRI #29

Open
eregon opened this issue Jan 20, 2020 · 18 comments
Open

Provide ruby.exe so it's a drop-in replacement for MRI #29

eregon opened this issue Jan 20, 2020 · 18 comments

Comments

@eregon
Copy link
Member

eregon commented Jan 20, 2020

See jruby/jruby#6042 (comment)

Currently it's not obvious how to make ruby ... work on Windows.
On Unix this is usually done easily with ln -s jruby ruby, but on Windows the only way I could find is to create a ruby.bat with:

@ECHO OFF
@"%~dp0jruby.exe" %*

(I also tried mklink on Windows, that doesn't work)

It would be nice if this could be simplified and e.g. JRuby already ships with that ruby.bat and ruby files.

gem, rake, etc already conflict with MRI binaries so the only way to use a Ruby is to add it to PATH anyway. Not having something for ruby ... means there is a the danger to use MRI for that one, but not for other commands such as gem and rake, which is never intended.

@eregon
Copy link
Member Author

eregon commented Jan 23, 2020

Having a 64-bit jruby.exe launcher would also be valuable:
jruby/jruby#6042 (comment)

@eregon
Copy link
Member Author

eregon commented Feb 8, 2020

@headius This became a problem again, see ruby/setup-ruby#18 (comment)

I'll copy the comments here for convenience:
Various issues here, once again with how to provide a ruby alias for jruby that works in both PowerShell and Bash:

Could we have a ruby.exe or make cp jruby.exe ruby.exe work?
.bat files are ignored in Bash on Windows.
So I think only .exe files work in both PwSh and Bash.

@eregon eregon changed the title Provide ruby and ruby.bat so it's a drop-in replacement for MRI Provide ruby.exe so it's a drop-in replacement for MRI Feb 8, 2020
@eregon
Copy link
Member Author

eregon commented Feb 8, 2020

Here are the executables provided on MRI built by RubyInstaller2:

$ ls -l rubyinstaller-2.5.7-1-x64/bin
total 3.3M
-rwxr-xr-x. 1 eregon eregon 4.8K Oct  2 00:54 erb
-rw-r--r--. 1 eregon eregon 4.9K Oct  2 00:54 erb.cmd
-rwxr-xr-x. 1 eregon eregon  546 Oct  2 00:54 gem
-rw-r--r--. 1 eregon eregon  688 Oct  2 00:54 gem.cmd
-rwxr-xr-x. 1 eregon eregon  190 Oct  2 00:54 irb
-rw-r--r--. 1 eregon eregon  360 Oct  2 00:54 irb.cmd
-rw-r--r--. 1 eregon eregon  729 Oct  2 00:54 rake
-rw-r--r--. 1 eregon eregon  153 Oct  2 00:54 rake.cmd
-rwxr-xr-x. 1 eregon eregon  938 Oct  2 00:54 rdoc
-rw-r--r--. 1 eregon eregon 1.1K Oct  2 00:54 rdoc.cmd
-rwxr-xr-x. 1 eregon eregon  188 Oct  2 00:54 ri
-rw-r--r--. 1 eregon eregon  330 Oct  2 00:54 ri.cmd
-rw-r--r--. 1 eregon eregon  694 Oct  2 00:54 ridk.cmd
-rw-r--r--. 1 eregon eregon  870 Oct  2 00:54 ridk.ps1
drwxr-xr-x. 2 eregon eregon 4.0K Oct  2 00:54 ruby_builtin_dlls
-rwxr-xr-x. 1 eregon eregon  35K Oct  2 00:54 ruby.exe
-rwxr-xr-x. 1 eregon eregon  35K Oct  2 00:54 rubyw.exe
-rw-r--r--. 1 eregon eregon  312 Oct  2 00:54 setrbvars.cmd
-rwxr-xr-x. 1 eregon eregon 3.1M Oct  2 00:54 x64-msvcrt-ruby250.dll

So having a ruby.exe seems the key.
And cp jruby.exe ruby.exe doesn't work currently unfortunately.

@headius
Copy link
Member

headius commented Feb 10, 2020

Is this only affecting Windows?

Most of the time we do not want to depend on the native launcher when the bash script works. If we could get rid of the native launcher we would, but it's needed on a few platforms (Darwin, Solaris) that don't support putting scripts into shebang lines.

@headius
Copy link
Member

headius commented Feb 10, 2020

FWIW I would be fine with JRuby publishing ruby as the primary executable (bash or native) with jruby just a script that launches it. There's almost never a good reason to have both jruby and an unrelated ruby in PATH.

@eregon
Copy link
Member Author

eregon commented Feb 10, 2020

Yes, it's only on Windows.
In PowerShell, the bash script would never be picked by ruby ....
So we need a reliable way to have ruby ... work in PowerShell for JRuby in Windows CIs.

The Bash script should also work with Bash on Windows, but currently it doesn't deal with quotes correctly.

My current workaround is copying the jruby Bash script to ruby, and adding ruby.bat but it's not perfect and it feels hacky I have to mess with the launchers manually:
https://github.com/ruby/ruby-builder/blob/b4e83abd2f97c1374f0e54cde134b359947df550/.github/workflows/build.yml#L108-L111

Could we maybe fix whatever in jruby.exe assumes the executable to be named jruby.exe? Then at least we could copy it to ruby.exe and that would hopefully work.
Even better would be to provide ruby.exe out of the box.

@headius
Copy link
Member

headius commented Feb 12, 2020

A trivial fix would be to have the launcher build and install both jruby.exe and ruby.exe.

Someone's going to have to get the launcher updated to support our .java_opts files very soon so this should get fixed at the same time.

@eregon
Copy link
Member Author

eregon commented Feb 16, 2020

Another reason is the latest jruby snapshot currently generates this for bundle.bat after gem install bundler:

@ECHO OFF
@"%~dp0ruby.exe" "%~dpn0" %*

Which is ruby.exe, not jruby.exe, so bundle probably doesn't work at all on Windows with the latest jruby snapshot:
https://oss.sonatype.org/content/repositories/snapshots/org/jruby/jruby-dist/9.2.10.0-SNAPSHOT/jruby-dist-9.2.10.0-20200214.210645-79-bin.tar.gz

https://github.com/ruby/jruby-dev-builder/runs/448860418

@headius
Copy link
Member

headius commented Feb 16, 2020

We do not generate those stubs... it's almost certainly something that has changed in RubyGems.

@deivid-rodriguez
Copy link
Contributor

This is rubygems issue rubygems/rubygems#2873 (a 3.0 specific regression caused by rubygems/rubygems#2119). It was fixed by rubygems/rubygems#2876, which is present in the latest rubygems but it was never backported to rubygems 3.0 (although it's been scheduled for backport to rubygems 3.0.7).

@hsbt Do you still intend to release rubygems 3.0.7 including rubygems/rubygems#2876?

@headius
Copy link
Member

headius commented Feb 16, 2020

If we can get RubyGems 3.0.7 I can update it for JRuby 9.2.10, due out VERY SOON.

@hsbt
Copy link

hsbt commented Feb 18, 2020

@hsbt Do you still intend to release rubygems 3.0.7 including rubygems/rubygems#2876?

I will release RG 3.0.7 in this week.

@hsbt
Copy link

hsbt commented Feb 18, 2020

Released https://blog.rubygems.org/2020/02/18/3.0.7-released.html

@deivid-rodriguez
Copy link
Contributor

Thanks for releasing so quickly @hsbt!

Unfortunately there's a regression in 3.0.7, could you have a look at rubygems/rubygems#3139?

@hsbt
Copy link

hsbt commented Feb 19, 2020

Also released 3.0.8

https://blog.rubygems.org/2020/02/19/3.0.8-released.html

@deivid-rodriguez Thanks for ping me.

@deivid-rodriguez
Copy link
Contributor

Thanks for the quick turnaround 💜! Unfortunately I don't think it made it into the jruby release, but it's good to have this fixed on the 3.x line :)

@headius
Copy link
Member

headius commented Feb 20, 2020

Since we are spinning 9.2.11 I will look at 3.0.8 and check that there's no other regressions.

@eregon
Copy link
Member Author

eregon commented Feb 21, 2020

FWIW, I pushed a quick fix for that issue to JRuby master, and looks like it made it in 9.2.10: jruby/jruby@4f5b1d6. Still would be better to use the fix from upstream of course.

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

No branches or pull requests

4 participants