Skip to content

Commit 30873ea

Browse files
committed
Handle ENXIO when /dev/tty cannot be opened
JRuby 9.4 seems to have trouble opening /dev/tty on Linux, so we fall back on stderr output and a hard raise to kill the build.
1 parent 378c026 commit 30873ea

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

extconf.rb

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,27 @@
1111
WARNING: See https://github.com/rbenv/ruby-build/pull/2517 for more details.
1212
MSG
1313

14+
# write a dummy makefile so no executable is built
15+
File.write("Makefile", dummy_makefile($srcdir).join(""))
16+
1417
# extconf.rb runs in a captured subprocess, so the only way to output is via /dev/tty
15-
if File.exist?("/dev/tty") && File.writable?("/dev/tty")
16-
error << <<~MSG
17-
WARNING:
18-
WARNING: The native jruby executable has not been installed.
19-
MSG
20-
File.write("/dev/tty", error)
21-
else
22-
# /dev/tty is not available, so write to stderr and raise
23-
$stderr.write(error)
24-
raise
18+
begin
19+
if File.exist?("/dev/tty") && File.writable?("/dev/tty")
20+
long_error = error + <<~MSG
21+
WARNING:
22+
WARNING: The native jruby executable has not been installed.
23+
MSG
24+
File.write("/dev/tty", long_error)
25+
return
26+
end
27+
rescue Errno::ENXIO
28+
# JRuby versions prior to 10 can't always open /dev/tty
29+
# Ignore and fail the install below
2530
end
26-
File.write("Makefile", dummy_makefile($srcdir).join(""))
27-
return
31+
32+
# /dev/tty is not available, so write to stderr and raise
33+
$stderr.write(error)
34+
raise Errno::ENOENT, "jruby.sh"
2835
end
2936

3037
# jruby.sh exists, proceed to build

0 commit comments

Comments
 (0)