Skip to content

Commit

Permalink
Make sure git gems are properly cached
Browse files Browse the repository at this point in the history
When using the `cache_all` setting, git gems are also cached. Also, when
using `--all-platforms`, gems for all platforms should be cached. Since
`git` gems supporting multiple platforms usually provide a single
gemspec, we need to special case that, otherwise the versions of the git
gems for platforms different than the running one wouldn't be found
because the gemspec would've been evaluated only for the current
platform.
  • Loading branch information
deivid-rodriguez committed Oct 20, 2020
1 parent 004560d commit 127e56e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bundler/lib/bundler/lazy_specification.rb
Expand Up @@ -79,7 +79,11 @@ def __materialize__
@specification = if source.is_a?(Source::Gemspec) && source.gemspec.name == name
source.gemspec.tap {|s| s.source = source }
else
search_object = Bundler.feature_flag.specific_platform? || Bundler.settings[:force_ruby_platform] ? self : Dependency.new(name, version)
search_object = if source.is_a?(Source::Path)
Dependency.new(name, version)
else
Bundler.feature_flag.specific_platform? || Bundler.settings[:force_ruby_platform] ? self : Dependency.new(name, version)
end
platform_object = Gem::Platform.new(platform)
candidates = source.specs.search(search_object)
same_platform_candidates = candidates.select do |spec|
Expand Down
35 changes: 35 additions & 0 deletions bundler/spec/install/gemfile/specific_platform_spec.rb
Expand Up @@ -33,6 +33,41 @@
to all(exist)
end

it "caches multiplatform git gems with a single gemspec when --all-platforms is passed" do
git = build_git "pg_array_parser", "1.0"

gemfile <<-G
gem "pg_array_parser", :git => "#{lib_path("pg_array_parser-1.0")}"
G

lockfile <<-L
GIT
remote: #{lib_path("pg_array_parser-1.0")}
revision: #{git.ref_for("master")}
specs:
pg_array_parser (1.0-java)
pg_array_parser (1.0)
GEM
specs:
PLATFORMS
java
#{lockfile_platforms}
DEPENDENCIES
pg_array_parser!
BUNDLED WITH
#{Bundler::VERSION}
L

bundle "config set --local cache_all true"
bundle "cache --all-platforms"

expect(err).to be_empty
end

it "uses the platform-specific gem with extra dependencies" do
setup_multiplatform_gem_with_different_dependencies_per_platform
install_gemfile <<-G
Expand Down

0 comments on commit 127e56e

Please sign in to comment.