Skip to content

Conversation

@headius
Copy link
Member

@headius headius commented Jun 25, 2025

This modifies our bin/ruby script to be exactly the same as the bin/jruby.sh script, in order to avoid shipping symlinks in our dist archives. This also avoids traversing a symlink when running the ruby command instead of jruby.

This also introduces bin/ruby.bat that relaunches from bin/jruby.exe.

These fixes are intended to avoid requiring workarounds as described in jruby/jruby-launcher#29 here:

jruby/jruby-launcher#29 (comment)

@headius headius added this to the JRuby 9.4.14.0 milestone Jun 25, 2025
@headius
Copy link
Member Author

headius commented Jun 25, 2025

This is an attempt to fix jruby/jruby-launcher#29 and workarounds that are apparently needed by setup-ruby and the jruby-dev-builder.

It might also make sense to have bin/ruby exec bin/jruby or vice versa, rather than having three copies of the launch script, but the extra copies don't really hurt anything.

@eregon
Copy link
Member

eregon commented Jun 25, 2025

That sounds good.
A possibility is to merge this and then try on a branch or PR of jruby-dev-builder removing the workarounds if it works as intended.

@headius
Copy link
Member Author

headius commented Jun 25, 2025

try on a branch or PR of jruby-dev-builder

Except this is to be merged into jruby-9.4, and you said you don't want to support head builds of jruby-9.4 in jruby-dev-builder.

If that can be changed, I'm willing to help set it up.

@eregon
Copy link
Member

eregon commented Jun 25, 2025

Shouldn't this also be merged on master and maybe tested there first?

@headius
Copy link
Member Author

headius commented Jun 25, 2025

When we intend a fix to go into an earlier release, we merge there first and then merge forward to master for current releases. We do not merge backwards due to the large number of changes that happen on master, and cherry-picking changes makes future merges more difficult.

It could be debated this change should not be applied to 9.4, though. @enebo ???

@enebo
Copy link
Member

enebo commented Jun 25, 2025 via email

@headius headius changed the base branch from jruby-9.4 to master June 26, 2025 23:06
@headius headius force-pushed the simpler_bin_ruby branch 2 times, most recently from dcc3992 to 524b5fe Compare June 26, 2025 23:07
@headius
Copy link
Member Author

headius commented Jun 26, 2025

@enebo Ok, I've rebased on current master.

I'll deploy it as a snapshot and test it in my fork of jruby-dev-builder.

headius added a commit to headius/jruby-dev-builder that referenced this pull request Jun 26, 2025
From jruby/jruby#8875:

* The bash script is now always installed as both `jruby` and
  `ruby`, so copying or linking is unnecessary.
* We now include in our distribution a `ruby.bat` so creating that
  is unnecessary.
This modifies our bin/ruby script to be exactly the same as the
bin/jruby.sh script, in order to avoid shipping symlinks in our
dist archives. This also avoids traversing a symlink when running
the `ruby` command instead of `jruby`.

This also introduces bin/ruby.bat that relaunches from
bin/jruby.exe.

These fixes are intended to avoid requiring workarounds as
described in jruby/jruby-launcher#29 here:

jruby/jruby-launcher#29 (comment)
@headius
Copy link
Member Author

headius commented Jun 26, 2025

Tested successfully here, with a snapshot made from this branch:

https://github.com/headius/jruby-dev-builder/actions/runs/15914550995/job/44889507971

I did think of an issue with having both bin/jruby and bin/ruby be a full launcher: jruby-launcher only overwrites bin/jruby. So, options:

  1. Modify jruby-launcher to overwrite both.
  2. Make bin/ruby just a small script that launches bin/jruby so it picks up the bin/jruby native binary from jruby-launcher.
  3. Do the same thing but make bin/ruby the master and modify jruby-launcher to overwrite that file.

I think only option 1 is viable.

Option 2 would mean that the bin/ruby executable would remain a shell script even after installing jruby-launcher, since only bin/jruby would be overwritten. It works with a symlink because the symlink just points at bin/jruby.

Option 3 would not be backward compatible with older JRuby releases that don't redirect bin/jruby to bin/ruby.

It might also be possible to get the bin/ruby symlink into the tarball, but that seems unreliable.

headius added a commit to headius/jruby-launcher that referenced this pull request Jun 26, 2025
@headius headius force-pushed the simpler_bin_ruby branch from 524b5fe to 7b5a66e Compare June 27, 2025 00:13
@headius
Copy link
Member Author

headius commented Jun 27, 2025

I have made changes to support Option 1 above.

  • Instead of copying bin/jruby.sh to bin/jruby and bin/ruby, the latter two simply exec bin/jruby.sh. That file becomes the true master launcher even when installing the native executable (on unix).
  • jruby-launcher will now overwrite both files with the native executable. Since they just exec bin/jruby.sh there's no change in behavior except that they can now be used in shebang lines on non-Linux unixes.

By having both aliases exec the master script, neither of them duplicate its contents.

By installing the native executable to both places, neither will fail to work in shebang lines.

We may want to consider encouraging people to use bin/ruby as their primary way to launch JRuby in the future, and modify RubyGems to use that in shebangs instead of bin/jruby.

@headius headius force-pushed the simpler_bin_ruby branch from 7b5a66e to 050ce2b Compare June 27, 2025 00:28
Rather than copying bin/jruby.sh to bin/jruby and bin/ruby during
the build, it makes more sense to just ship scripts already in
place that exec bin/jruby.sh. This makes that file the true main
launcher, since even the native executable on unix now execs.

Shell code provided by @mrnoname1000.
@headius headius force-pushed the simpler_bin_ruby branch from 050ce2b to 8bbeec6 Compare June 27, 2025 00:40
@headius
Copy link
Member Author

headius commented Jun 27, 2025

I'm re-pushing a snapshot without these changes to avoid breaking anyone using jruby-dev-builder nightlies, but I think almost everything is in place:

This PR:

  • adds bin/jruby and bin/ruby that source bin/jruby.sh and removes copying from the build
  • adds bin/ruby.bat that relaunches bin/jruby.exe.

This eliminates the workarounds discussed in jruby/jruby-launcher#29.

jruby/jruby-launcher#54:

  • installs the native executable in both aliases, replacing bin/jruby and bin/ruby, but also just redirects to bin/jruby.sh.

I'm not going to mess with this too much more until we can discuss.

@headius headius marked this pull request as ready for review July 8, 2025 16:33
@headius headius merged commit bfc14e6 into jruby:master Jul 8, 2025
142 of 144 checks passed
@headius headius deleted the simpler_bin_ruby branch July 8, 2025 16:34
headius added a commit to headius/jruby-launcher that referenced this pull request Jul 9, 2025
headius added a commit to headius/jruby-dev-builder that referenced this pull request Jul 21, 2025
In jruby/jruby#8875 we modified JRuby's distribution to always
ship scripts for bin/jruby and bin/ruby:

* bin/jruby and bin/ruby are versioned shell scripts that launch
  `/bin/sh bin/jruby.sh`.
* bin/ruby.bat contains batch code to launch bin/ruby.exe.
* No copying of scripts is done during the build and no tweaks are
  needed by installers to copy, link, or create additional bin/
  commands.

These changes now conflict with jruby-dev-builder's symlinking of
bin/jruby to bin/ruby and its creation of bin/ruby.bat, so we
remove the relevant steps.
eregon pushed a commit to ruby/jruby-dev-builder that referenced this pull request Jul 21, 2025
In jruby/jruby#8875 we modified JRuby's distribution to always
ship scripts for bin/jruby and bin/ruby:

* bin/jruby and bin/ruby are versioned shell scripts that launch
  `/bin/sh bin/jruby.sh`.
* bin/ruby.bat contains batch code to launch bin/ruby.exe.
* No copying of scripts is done during the build and no tweaks are
  needed by installers to copy, link, or create additional bin/
  commands.

These changes now conflict with jruby-dev-builder's symlinking of
bin/jruby to bin/ruby and its creation of bin/ruby.bat, so we
remove the relevant steps.
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.

3 participants