diff options
author | Steven Davidovitz <sdavidovitz@zendesk.com> | 2015-07-31 10:17:36 -0700 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2015-08-13 21:31:52 -0700 |
commit | 02aa3e6d09778eb67ce74ee81c0ac18ec6bade92 (patch) | |
tree | d16fa36a97c744b1eda6c51703472878231d325e | |
parent | 6fdbc5d2ac7d794df8044dc7e3c1ce99922e3ff1 (diff) | |
download | bundler-02aa3e6d09778eb67ce74ee81c0ac18ec6bade92.tar.gz |
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 0c408b4bbf..789ec0deb5 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..752a1ee5f9 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" |