summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2022-12-14 02:16:43 +0900
committergit <[email protected]>2024-07-18 04:20:07 +0000
commitc032e2c225f4c20ba35cc40a3dd00eef9ae62cfd (patch)
treef722c2955279f488dac914176f9ff15882e610e5 /lib
parentc639bacd454dcf43619591f0f0eaa1ac7226f77c (diff)
[rubygems/rubygems] Use `caller_locations` instead of splitting `caller`
Also limit caller ranges https://github.com/rubygems/rubygems/commit/a274b1af78
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/env.rb2
-rw-r--r--lib/bundler/rubygems_integration.rb2
-rw-r--r--lib/rubygems/specification.rb2
3 files changed, 3 insertions, 3 deletions
diff --git a/lib/bundler/env.rb b/lib/bundler/env.rb
index f6cb198e38..074bef6edc 100644
--- a/lib/bundler/env.rb
+++ b/lib/bundler/env.rb
@@ -120,7 +120,7 @@ module Bundler
specs = Bundler.rubygems.find_name(name)
out << [" #{name}", "(#{specs.map(&:version).join(",")})"] unless specs.empty?
end
- if (exe = caller.last.split(":").first)&.match? %r{(exe|bin)/bundler?\z}
+ if (exe = caller_locations.last.absolute_path)&.match? %r{(exe|bin)/bundler?\z}
shebang = File.read(exe).lines.first
shebang.sub!(/^#!\s*/, "")
unless shebang.start_with?(Gem.ruby, "/usr/bin/env ruby")
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index 1302333510..72dead88f2 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -220,7 +220,7 @@ module Bundler
[::Kernel.singleton_class, ::Kernel].each do |kernel_class|
redefine_method(kernel_class, :gem) do |dep, *reqs|
- if executables&.include?(File.basename(caller.first.split(":").first))
+ if executables&.include?(File.basename(caller_locations(1, 1).first.path))
break
end
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 7160064dd2..ec2055c4ab 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -874,7 +874,7 @@ class Gem::Specification < Gem::BasicSpecification
# You probably want to use one of the Enumerable methods instead.
def self.all
- warn "NOTE: Specification.all called from #{caller.first}" unless
+ warn "NOTE: Specification.all called from #{caller(1, 1).first}" unless
Gem::Deprecate.skip
_all
end