From 5911a5231e6ec7bb50e15886ec2f3c5aae4e175e Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 30 Jan 2026 11:01:49 +0900 Subject: [ruby/rubygems] Handle symlink TMPDIR with macOS https://github.com/ruby/rubygems/commit/cf08f1ec4c --- spec/bundler/bundler/gem_helper_spec.rb | 1 + spec/bundler/support/path.rb | 12 +++++++++++- spec/bundler/support/rubygems_ext.rb | 13 ++++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) (limited to 'spec') 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 -- cgit v1.2.3