ruby/tool/rubyspec_temp.rb
Nobuyoshi Nakada de5cd5a635
Use shorter path as SPEC_TEMP_DIR
The temporary directory under the build directory may be too long as a
UNIX socket path.  On macOS, the default `TMPDIR` per user is also
very long.
2023-04-21 22:24:55 +09:00

14 lines
386 B
Ruby

require "tmpdir"
require "fileutils"
if (tmpdir = Dir.mktmpdir("rubyspec_temp.")).size > 80
# On macOS, the default TMPDIR is very long, inspite of UNIX socket
# path length is limited.
Dir.rmdir(tmpdir)
tmpdir = Dir.mktmpdir("rubyspec_temp.", "/tmp")
end
# warn "tmpdir(#{tmpdir.size}) = #{tmpdir}"
END {FileUtils.rm_rf(tmpdir)}
ENV["TMPDIR"] = ENV["SPEC_TEMP_DIR"] = tmpdir