Skip to content

Commit d61b643

Browse files
committed
Support git source in Gemfile
1 parent 25155aa commit d61b643

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

ruby/private/bundle/create_bundle_build_file.rb

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,23 @@ def register_gem(spec, template_out, bundle_lib_paths, bundle_binaries)
252252
# Do not register local gems
253253
return if spec.source.path?
254254

255-
gem_path = GEM_PATH[ruby_version, spec.name, spec.version]
256-
spec_path = SPEC_PATH[ruby_version, spec.name, spec.version]
257-
base_dir = "lib/ruby/#{ruby_version}"
255+
if spec.source.is_a?(Bundler::Source::Git)
256+
stub = spec.source.specs.find { |s| s.name == spec.name }.stub
257+
base_dir = "lib/ruby/#{ruby_version}"
258+
gem_path = "#{base_dir}/bundler/gems/#{Pathname(stub.full_gem_path).relative_path_from(stub.base_dir)}"
259+
spec_path = "#{base_dir}/bundler/gems/#{Pathname(stub.loaded_from).relative_path_from(stub.base_dir)}"
260+
261+
# paths to register to $LOAD_PATH
262+
require_paths = stub.require_paths
263+
else
264+
gem_path = GEM_PATH[ruby_version, spec.name, spec.version]
265+
spec_path = SPEC_PATH[ruby_version, spec.name, spec.version]
266+
base_dir = "lib/ruby/#{ruby_version}"
267+
268+
# paths to register to $LOAD_PATH
269+
require_paths = Gem::StubSpecification.gemspec_stub(spec_path, base_dir, "#{base_dir}/gems").require_paths
270+
end
258271

259-
# paths to register to $LOAD_PATH
260-
require_paths = Gem::StubSpecification.gemspec_stub(spec_path, base_dir, "#{base_dir}/gems").require_paths
261272
# Usually, registering the directory paths listed in the `require_paths` of gemspecs is sufficient, but
262273
# some gems also require additional paths to be included in the load paths.
263274
require_paths += include_array(spec.name)

0 commit comments

Comments
 (0)