Skip to content

Commit 1048779

Browse files
committed
Check for jruby.sh on install and warn or error
The skinny launcher on unix requires that JRuby's jruby.sh be present in the target installation. If it is not, we try to log a warning to /dev/tty indicating that the native executable will not be installed. If we cannot write to /dev/tty, we log the same warning but fail the extconf build. The warning explains the situation, links to the ruby-build issue about deleting jruby.sh, and recommends upgrading the host Ruby manager.
1 parent 6d8ebcb commit 1048779

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

extconf.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
# check for jruby.sh used by new unix launcher
2+
if !File.exist?(File.join(RbConfig::CONFIG['bindir'], "jruby.sh"))
3+
require 'mkmf'
4+
error = <<~MSG
5+
WARNING: This JRuby install does not contain bin/jruby.sh and is not compatible
6+
WARNING: with jruby-launcher 2.0+.
7+
WARNING:
8+
WARNING: If you are using ruby-build to install (or a Ruby manager like rbenv)
9+
WARNING: please upgrade to latest and reinstall jruby-launcher.
10+
WARNING:
11+
WARNING: See https://github.com/rbenv/ruby-build/pull/2517 for more details.
12+
MSG
13+
if File.exist?("/dev/tty")
14+
error << <<~MSG
15+
WARNING:
16+
WARNING: The native jruby executable has not been installed.
17+
MSG
18+
File.write("/dev/tty", error)
19+
else
20+
$stderr.write(error)
21+
end
22+
File.write("Makefile", dummy_makefile($srcdir).join(""))
23+
return
24+
end
25+
26+
# jruby.sh exists, proceed to build
127
mf = File.read('Makefile')
228
mf = mf.gsub(/^BINDIR\s*=.*$/, "BINDIR = #{RbConfig::CONFIG['bindir']}")
329
mf = mf.gsub(/^PREFIX\s*=.*$/, "PREFIX = #{File.dirname(RbConfig::CONFIG['libdir'])}")

0 commit comments

Comments
 (0)