Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixes #744: Keep relative paths in Gemfile.lock when using Source::Path

  • Loading branch information...
commit 86319c643d8114fdac6dbaf8476f313d00e38874 1 parent aad1d32
Antono Vasiljev authored
15 lib/bundler/source.rb
@@ -276,7 +276,8 @@ def initialize(options)
276 276 @allow_remote = false
277 277
278 278 if options["path"]
279   - @path = Pathname.new(options["path"]).expand_path(Bundler.root)
  279 + @path = Pathname.new(options["path"])
  280 + @path = @path.expand_path(Bundler.root) unless @path.relative?
280 281 end
281 282
282 283 @name = options["name"]
@@ -326,8 +327,10 @@ def name
326 327 def load_spec_files
327 328 index = Index.new
328 329
329   - if File.directory?(path)
330   - Dir["#{path}/#{@glob}"].each do |file|
  330 + expanded_path = path.expand_path
  331 +
  332 + if File.directory?(expanded_path)
  333 + Dir["#{expanded_path}/#{@glob}"].each do |file|
331 334 spec = Bundler.load_gemspec(file)
332 335 if spec
333 336 spec.loaded_from = file.to_s
@@ -344,14 +347,14 @@ def load_spec_files
344 347 s.platform = Gem::Platform::RUBY
345 348 s.summary = "Fake gemspec for #{@name}"
346 349 s.relative_loaded_from = "#{@name}.gemspec"
347   - if path.join("bin").exist?
348   - binaries = path.join("bin").children.map{|c| c.basename.to_s }
  350 + if expanded_path.join("bin").exist?
  351 + binaries = expanded_path.join("bin").children.map{|c| c.basename.to_s }
349 352 s.executables = binaries
350 353 end
351 354 end
352 355 end
353 356 else
354   - raise PathError, "The path `#{path}` does not exist."
  357 + raise PathError, "The path `#{expanded_path}` does not exist."
355 358 end
356 359
357 360 index
2  spec/install/path_spec.rb
@@ -37,7 +37,7 @@
37 37 it "expands paths" do
38 38 build_lib "foo"
39 39
40   - relative_path = lib_path('foo-1.0').relative_path_from(Pathname.new("~").expand_path)
  40 + relative_path = lib_path('foo-1.0').relative_path_from(Pathname.new('~').expand_path)
41 41
42 42 install_gemfile <<-G
43 43 gem 'foo', :path => "~/#{relative_path}"
27 spec/lock/flex_spec.rb
@@ -375,7 +375,7 @@
375 375 G
376 376 end
377 377
378   - it "stores relative paths when the path is provided in a relative fashion" do
  378 + it "stores relative paths when the path is provided in a relative fashion and in Gemfile dir" do
379 379 build_lib "foo", :path => bundled_app('foo')
380 380
381 381 install_gemfile <<-G
@@ -400,6 +400,31 @@
400 400 G
401 401 end
402 402
  403 + it "stores relative paths when the path is provided in a relative fashion and is above Gemfile dir" do
  404 + build_lib "foo", :path => bundled_app(File.join('..', 'foo'))
  405 +
  406 + install_gemfile <<-G
  407 + path "../foo"
  408 + gem "foo"
  409 + G
  410 +
  411 + lockfile_should_be <<-G
  412 + PATH
  413 + remote: ../foo
  414 + specs:
  415 + foo (1.0)
  416 +
  417 + GEM
  418 + specs:
  419 +
  420 + PLATFORMS
  421 + #{generic(Gem::Platform.local)}
  422 +
  423 + DEPENDENCIES
  424 + foo
  425 + G
  426 + end
  427 +
403 428 it "stores relative paths when the path is provided in an absolute fashion but is relative" do
404 429 build_lib "foo", :path => bundled_app('foo')
405 430

0 comments on commit 86319c6

Please sign in to comment.
Something went wrong with that request. Please try again.