diff options
author | Yuta Saito <[email protected]> | 2022-07-16 18:21:15 +0000 |
---|---|---|
committer | git <[email protected]> | 2022-07-17 19:44:51 +0900 |
commit | fab8f3bde6e4d1ac78aa63e4768452b3da0f955e (patch) | |
tree | 368b86557edcfa0b983e5295c3758a7f8468fc87 /lib/rubygems/user_interaction.rb | |
parent | 5081d0dd5c366ebaee084fd67289bebe23ddb152 (diff) |
[rubygems/rubygems] Stop using `/dev/null` for silent ui for WASI platform
WASI doesn't guarantee that `/dev/null` is present.
So without this patch, we needed to mount host's `/dev` directory to WASI
guest process to avoid `ENOTCAPABLE` error while `require "bundler/setup"`
https://github.com/rubygems/rubygems/commit/e9187ab61f
Diffstat (limited to 'lib/rubygems/user_interaction.rb')
-rw-r--r-- | lib/rubygems/user_interaction.rb | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/lib/rubygems/user_interaction.rb b/lib/rubygems/user_interaction.rb index e632f418a9..c726fd21c1 100644 --- a/lib/rubygems/user_interaction.rb +++ b/lib/rubygems/user_interaction.rb @@ -616,18 +616,11 @@ class Gem::SilentUI < Gem::StreamUI # The SilentUI has no arguments as it does not use any stream. def initialize - reader, writer = nil, nil - - reader = File.open(IO::NULL, 'r') - writer = File.open(IO::NULL, 'w') - - super reader, writer, writer, false + io = NullIO.new + super io, io, io, false end def close - super - @ins.close - @outs.close end def download_reporter(*args) # :nodoc: @@ -637,4 +630,25 @@ class Gem::SilentUI < Gem::StreamUI def progress_reporter(*args) # :nodoc: SilentProgressReporter.new(@outs, *args) end + + ## + # An absolutely silent IO. + + class NullIO + def puts(*args) + end + + def print(*args) + end + + def flush + end + + def gets(*args) + end + + def tty? + false + end + end end |