diff options
author | Homu <homu@barosl.com> | 2015-08-30 12:32:03 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2015-08-30 12:32:03 +0900 |
commit | 21059b4ec2af38bf7ef9ddc233ca393259c97a9b (patch) | |
tree | f855111b532ae70577d4ecc9ff26910df53dc46d | |
parent | 795ebe3b2bc178629a3d4e157744ae00c13ac891 (diff) | |
parent | 6578473f2c459d7e396b49e7512337f4dbb5387d (diff) | |
download | bundler-21059b4ec2af38bf7ef9ddc233ca393259c97a9b.tar.gz |
Auto merge of #3907 - bundler:fix-path-caching-3900, r=segiddins
make sure intersecting gem paths are cached
When a gem has the same path prefix as the application that is being bundled,
the gem will not be added to vendor/cache.
For example: a gem with a path /home/test/src/bundled_gem and an application with a path
/home/test/src/bundled that references it.
-rw-r--r-- | lib/bundler/source/path.rb | 2 | ||||
-rw-r--r-- | spec/cache/path_spec.rb | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb index b2c2f8c978..d47fe0dea6 100644 --- a/lib/bundler/source/path.rb +++ b/lib/bundler/source/path.rb @@ -77,7 +77,7 @@ module Bundler def cache(spec, custom_path = nil) app_cache_path = app_cache_path(custom_path) return unless Bundler.settings[:cache_all] - return if expand(@original_path).to_s.index(Bundler.root.to_s) == 0 + return if expand(@original_path).to_s.index(Bundler.root.to_s + "/") == 0 unless @original_path.exist? raise GemNotFound, "Can't cache gem #{version_message(spec)} because #{self} is missing!" diff --git a/spec/cache/path_spec.rb b/spec/cache/path_spec.rb index 324e1f131e..82dfce94ba 100644 --- a/spec/cache/path_spec.rb +++ b/spec/cache/path_spec.rb @@ -29,6 +29,24 @@ require "spec_helper" should_be_installed "foo 1.0" end + it "copies when the path is outside the bundle and the paths intersect" do + libname = File.basename(Dir.pwd) + "_gem" + libpath = File.join(File.dirname(Dir.pwd), libname) + + build_lib libname, :path => libpath + + install_gemfile <<-G + gem "#{libname}", :path => '#{libpath}' + G + + bundle "#{cmd} --all" + expect(bundled_app("vendor/cache/#{libname}")).to exist + expect(bundled_app("vendor/cache/#{libname}/.bundlecache")).to be_file + + FileUtils.rm_rf libpath + should_be_installed "#{libname} 1.0" + end + it "updates the path on each cache" do build_lib "foo" |