diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb index 8084a530d1..8118c2b2e7 100644 --- a/lib/bundler/fetcher.rb +++ b/lib/bundler/fetcher.rb @@ -99,7 +99,7 @@ module Bundler uri = URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz") if uri.scheme == "file" - path = Gem.win_platform? ? uri.path[1..-1] : uri.path + path = Bundler.rubygems.correct_for_windows_path(uri.path) Bundler.load_marshal Bundler.rubygems.inflate(Gem.read_binary(path)) elsif cached_spec_path = gemspec_cached_path(spec_file_name) Bundler.load_gemspec(cached_spec_path) diff --git a/lib/bundler/fetcher/index.rb b/lib/bundler/fetcher/index.rb index d10c21b041..d2ad657fe6 100644 --- a/lib/bundler/fetcher/index.rb +++ b/lib/bundler/fetcher/index.rb @@ -30,7 +30,7 @@ module Bundler uri = URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz") if uri.scheme == "file" - path = Gem.win_platform? ? uri.path[1..-1] : uri.path + path = Bundler.rubygems.correct_for_windows_path(uri.path) Bundler.load_marshal Bundler.rubygems.inflate(Gem.read_binary(path)) elsif cached_spec_path = gemspec_cached_path(spec_file_name) Bundler.load_gemspec(cached_spec_path) diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index 9df0897ca2..3e74acf694 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -146,6 +146,18 @@ module Bundler end end + def correct_for_windows_path(path) + require "rubygems/util" + + if Gem::Util.respond_to?(:correct_for_windows_path) + Gem::Util.correct_for_windows_path(path) + elsif path[0].chr == "/" && path[1].chr =~ /[a-z]/i && path[2].chr == ":" + path[1..-1] + else + path + end + end + def sources=(val) # Gem.configuration creates a new Gem::ConfigFile, which by default will read ~/.gemrc # If that file exists, its settings (including sources) will overwrite the values we