1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[rubygems/rubygems] Fix standalone generated script to deal with path sources

In the case of path sources, the path the source is pointing to should
be added directly to the `$LOAD_PATH` without any modifications.

https://github.com/rubygems/rubygems/commit/d3bba936f0

Co-authored-by: Daniel Niknam <mhmd.niknam@gmail.com>
This commit is contained in:
David Rodríguez 2021-07-27 19:43:01 +02:00 committed by Hiroshi SHIBATA
parent 7465b94f8a
commit f1c0729128
Notes: git 2021-08-31 19:07:22 +09:00
2 changed files with 40 additions and 2 deletions

View file

@ -14,7 +14,11 @@ module Bundler
file.puts "require 'rbconfig'"
file.puts reverse_rubygems_kernel_mixin
paths.each do |path|
file.puts %($:.unshift File.expand_path("\#{__dir__}/#{path}"))
if Pathname.new(path).absolute?
file.puts %($:.unshift "#{path}")
else
file.puts %($:.unshift File.expand_path("\#{__dir__}/#{path}"))
end
end
end
end
@ -41,7 +45,11 @@ module Bundler
def gem_path(path, spec)
full_path = Pathname.new(path).absolute? ? path : File.join(spec.full_gem_path, path)
Pathname.new(full_path).relative_path_from(Bundler.root.join(bundler_path)).to_s
if spec.source.instance_of?(Source::Path)
full_path
else
Pathname.new(full_path).relative_path_from(Bundler.root.join(bundler_path)).to_s
end
rescue TypeError
error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
raise Gem::InvalidSpecificationException.new(error_message)

View file

@ -147,6 +147,36 @@ RSpec.shared_examples "bundle install --standalone" do
end
end
describe "with Gemfiles using path sources and resulting bundle moved to a folder hierarchy with different nesting" do
before do
build_lib "minitest", "1.0.0", :path => lib_path("minitest")
Dir.mkdir bundled_app("app")
gemfile bundled_app("app/Gemfile"), <<-G
source "#{file_uri_for(gem_repo1)}"
gem "minitest", :path => "#{lib_path("minitest")}"
G
bundle "install", :standalone => true, :dir => bundled_app("app")
Dir.mkdir tmp("one_more_level")
FileUtils.mv bundled_app, tmp("one_more_level")
end
it "also works" do
ruby <<-RUBY, :dir => tmp("one_more_level/bundled_app/app")
require "./bundle/bundler/setup"
require "minitest"
puts MINITEST
RUBY
expect(out).to eq("1.0.0")
expect(err).to be_empty
end
end
describe "with gems with native extension", :ruby_repo do
before do
bundle "config set --local path #{bundled_app("bundle")}"