summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2026-01-30 11:01:49 +0900
committergit <svn-admin@ruby-lang.org>2026-01-30 05:08:16 +0000
commit5911a5231e6ec7bb50e15886ec2f3c5aae4e175e (patch)
tree8ac062bf580f7d3aceb3dc0740d09e86e925f492 /spec
parent9bf8aaa26460b056236738a98521149f38611f88 (diff)
[ruby/rubygems] Handle symlink TMPDIR with macOS
https://github.com/ruby/rubygems/commit/cf08f1ec4c
Diffstat (limited to 'spec')
-rw-r--r--spec/bundler/bundler/gem_helper_spec.rb1
-rw-r--r--spec/bundler/support/path.rb12
-rw-r--r--spec/bundler/support/rubygems_ext.rb13
3 files changed, 24 insertions, 2 deletions
diff --git a/spec/bundler/bundler/gem_helper_spec.rb b/spec/bundler/bundler/gem_helper_spec.rb
index 94f66537d3..83c2dd237a 100644
--- a/spec/bundler/bundler/gem_helper_spec.rb
+++ b/spec/bundler/bundler/gem_helper_spec.rb
@@ -386,6 +386,7 @@ RSpec.describe Bundler::GemHelper do
credentials = double("credentials", "file?" => true)
allow(Bundler.user_home).to receive(:join).
with(".gem/credentials").and_return(credentials)
+ allow(Bundler.user_home).to receive(:join).and_call_original
end
describe "success messaging" do
diff --git a/spec/bundler/support/path.rb b/spec/bundler/support/path.rb
index 1c49def88d..679f54152b 100644
--- a/spec/bundler/support/path.rb
+++ b/spec/bundler/support/path.rb
@@ -114,7 +114,17 @@ module Spec
end
def tmp_root
- ruby_core? && (tmpdir = ENV["TMPDIR"]) ? Pathname(tmpdir) : source_root.join("tmp")
+ if ruby_core? && (tmpdir = ENV["TMPDIR"])
+ # Use realpath to resolve any symlinks in TMPDIR (e.g., on macOS /var -> /private/var)
+ real = begin
+ File.realpath(tmpdir)
+ rescue Errno::ENOENT, Errno::EACCES
+ tmpdir
+ end
+ Pathname(real)
+ else
+ source_root.join("tmp")
+ end
end
# Bump this version whenever you make a breaking change to the spec setup
diff --git a/spec/bundler/support/rubygems_ext.rb b/spec/bundler/support/rubygems_ext.rb
index f168c70487..cf639a660a 100644
--- a/spec/bundler/support/rubygems_ext.rb
+++ b/spec/bundler/support/rubygems_ext.rb
@@ -43,7 +43,18 @@ module Spec
# sign extension bundles on macOS, to avoid trying to find the specified key
# from the fake $HOME/Library/Keychains directory.
ENV.delete "RUBY_CODESIGN"
- ENV["TMPDIR"] = Path.tmpdir.to_s unless Path.ruby_core?
+ if Path.ruby_core?
+ if (tmpdir = ENV["TMPDIR"])
+ tmpdir_real = begin
+ File.realpath(tmpdir)
+ rescue Errno::ENOENT, Errno::EACCES
+ tmpdir
+ end
+ ENV["TMPDIR"] = tmpdir_real if tmpdir_real != tmpdir
+ end
+ else
+ ENV["TMPDIR"] = Path.tmpdir.to_s
+ end
require "rubygems/user_interaction"
Gem::DefaultUserInteraction.ui = Gem::SilentUI.new