Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1582 from carlhuda/relative_path
Browse files Browse the repository at this point in the history
fix relative_path so it checks Bundler.root is actually in the beginning of the path
  • Loading branch information
André Arko committed Dec 9, 2011
2 parents 3b836fc + 4b9ca12 commit 6d431b8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bundler/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def cache(spec)
private

def relative_path
if path.to_s.include?(Bundler.root.to_s)
if path.to_s.match(%r{^#{Bundler.root.to_s}})
return path.relative_path_from(Bundler.root)
end

Expand Down
25 changes: 25 additions & 0 deletions spec/runtime/setup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,31 @@
end
err.should == ""
end

it "should make sure the Bundler.root is really included in the path relative to the Gemfile" do
relative_path = File.join('vendor', Dir.pwd[1..-1], 'foo')
absolute_path = bundled_app(relative_path)
FileUtils.mkdir_p(absolute_path)
build_lib "foo", :path => absolute_path

# If the .gemspec exists, then Bundler handles the path differently.
# See Source::Path.load_spec_files for details.
FileUtils.rm(File.join(absolute_path, 'foo.gemspec'))

gemfile <<-G
gem 'foo', '1.2.3', :path => '#{relative_path}'
G

bundle :install

Dir.chdir(bundled_app.parent) do
run <<-R, :env => {"BUNDLE_GEMFILE" => bundled_app('Gemfile')}
require 'foo'
R
end

err.should == ""
end
end

describe "with git gems that don't have gemspecs" do
Expand Down

0 comments on commit 6d431b8

Please sign in to comment.