Skip to content

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

Description

@eregon

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.

Activity

  1. eregon commented on Jan 23, 2020

    @eregon
    Author

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

  2. eregon commented on Feb 8, 2020

    @eregon
    Author

    @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.

  3. 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[/+] on Feb 8, 2020
  4. eregon commented on Feb 8, 2020

    @eregon
    Author

    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.

  5. headius commented on Feb 10, 2020

    @headius
    Member

    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.

  6. headius commented on Feb 10, 2020

    @headius
    Member

    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.

  7. eregon commented on Feb 10, 2020

    @eregon
    Author

    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.

  8. headius commented on Feb 12, 2020

    @headius
    Member

    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.

  9. eregon commented on Feb 16, 2020

    @eregon
    Author

    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

  10. headius commented on Feb 16, 2020

    @headius
    Member

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

  11. deivid-rodriguez commented on Feb 16, 2020

    @deivid-rodriguez
    Contributor

    This is rubygems issue ruby/rubygems#2873 (a 3.0 specific regression caused by ruby/rubygems#2119). It was fixed by ruby/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 ruby/rubygems#2876?

  12. headius commented on Feb 16, 2020

    @headius
    Member

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

  13. hsbt commented on Feb 18, 2020

    @hsbt

    @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.

  14. hsbt commented on Feb 18, 2020

    @hsbt
  15. deivid-rodriguez commented on Feb 18, 2020

    @deivid-rodriguez
    Contributor

    Thanks for releasing so quickly @hsbt!

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

  16. 6 remaining items

  17. eregon commented on Jun 25, 2025

    @eregon
    Author

    BTW there is also https://github.com/ruby/jruby-dev-builder/blob/841382ecf34207d4dbf921557e4c8fc2fa02f28f/.github/workflows/build.yml#L118-L122 on non-Windows and basically all Ruby installers need to work around that by symlinking manually, it'd be best to not need that.

  18. headius commented on Jun 25, 2025

    @headius
    Member

    The issue is that repo still needs to workaround

    So adding that same ruby.bat to our distribution would be enough for now?

    basically all Ruby installers need to work around that by symlinking manually

    JRuby already links bin/ruby to bin/jruby. Is that not sufficient?

    It may be better in the long run to just ship the shell script as both bin/jruby and bin/ruby and the native executable as both jruby.exe and ruby.exe.

  19. added a commit that references this issue on Jun 25, 2025
  20. eregon commented on Jun 25, 2025

    @eregon
    Author

    So adding that same ruby.bat to our distribution would be enough for now?

    Doing the same commands but before creating the JRuby archive should work, yes.
    I'm not sure it's the best solution, it's just a solution I found that works in GitHub Actions.

    JRuby already links bin/ruby to bin/jruby. Is that not sufficient?

    It doesn't: https://github.com/ruby/jruby-dev-builder/actions/runs/15450501641/job/43491183427#step:8:48
    Looking at https://github.com/jruby/jruby/releases/download/10.0.0.1/jruby-bin-10.0.0.1.tar.gz there is no bin/ruby either.

    It may be better in the long run to just ship the shell script as both bin/jruby and bin/ruby and the native executable as both jruby.exe and ruby.exe.

    Yes, that sounds like a proper solution that would work for a single archive for POSIX & Windows.
    Though there was an issue with just copying the .exe and it errored IIRC but that should be easy to test if still a problem.

  21. headius commented on Jun 25, 2025

    @headius
    Member

    I have opened jruby/jruby#8875 to copy bin/jruby.sh to both bin/jruby and bin/ruby, and also include the known-working bin/ruby.bat in our distributions.

    Looking at https://github.com/jruby/jruby/releases/download/10.0.0.1/jruby-bin-10.0.0.1.tar.gz there is no bin/ruby either.

    The tarball build must not be including the symlink. It was intended to. The PR eliminates the symlink and makes it another copy of the shell script.

  22. headius commented on Jun 25, 2025

    @headius
    Member

    It doesn't

    It does: https://github.com/jruby/jruby/blob/master/bin/ruby

    Seems like it's a build problem or an issue generating the tarball.

  23. headius commented on Jul 9, 2025

    @headius
    Member

    This should be fixed by #54.

  24. headius commented on Jul 9, 2025

    @headius
    Member

    Correction:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions