Skip to content

Commit

Permalink
override gem that have no path (and no version)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrock committed Jan 16, 2024
1 parent 2fd8e3c commit 185626a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/bundler/inject/dsl_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,15 @@ def remove_dependencies_and_sources(dependency)
# This is used when an override has no options or a path is specified
# This path is turned into an absolute path
def expand_gem_path(name, args, calling_file)
args << {:path => name} if args.empty?
return unless args.last.kind_of?(Hash) && args.last[:path]
return unless args.empty? || args.last.kind_of?(Hash) && args.last[:path]

path = args.empty? ? name : args.last[:path]
possible_paths = [File.dirname(calling_file)] + bundler_inject_gem_path
full_path = possible_paths.map { |p| File.expand_path(args.last[:path], p) }.detect { |f| File.exist?(f) }
args.last[:path] = full_path if full_path
full_path = possible_paths.map { |p| File.expand_path(path, p) }.detect { |f| File.exist?(f) }
if full_path
args << {} if args.empty?
args.last[:path] = full_path
end
end

def extract_version_opts(args)
Expand Down

0 comments on commit 185626a

Please sign in to comment.