@@ -252,12 +252,22 @@ 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 ]
257255 base_dir = "lib/ruby/#{ ruby_version } "
256+ if spec . source . is_a? ( Bundler ::Source ::Git )
257+ stub = spec . source . specs . find { |s | s . name == spec . name } . stub
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+
267+ # paths to register to $LOAD_PATH
268+ require_paths = Gem ::StubSpecification . gemspec_stub ( spec_path , base_dir , "#{ base_dir } /gems" ) . require_paths
269+ end
258270
259- # paths to register to $LOAD_PATH
260- require_paths = Gem ::StubSpecification . gemspec_stub ( spec_path , base_dir , "#{ base_dir } /gems" ) . require_paths
261271 # Usually, registering the directory paths listed in the `require_paths` of gemspecs is sufficient, but
262272 # some gems also require additional paths to be included in the load paths.
263273 require_paths += include_array ( spec . name )
0 commit comments