diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index c41f3ce535c..018b6833ef2 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -46,8 +46,7 @@ def gemspec(opts = nil) path = opts && opts[:path] || '.' name = opts && opts[:name] || '{,*}' development_group = opts && opts[:development_group] || :development - gemfile = @gemfile || Bundler.default_gemfile - expanded_path = File.expand_path(path, gemfile.dirname) + expanded_path = path_relative_to_gemfile(path) gemspecs = Dir[File.join(expanded_path, "#{name}.gemspec")] @@ -133,7 +132,7 @@ def git_source(name, &block) end def path(path, options = {}, &blk) - with_source(@sources.add_path_source(normalize_hash(options).merge("path" => Pathname.new(path))), &blk) + with_source(@sources.add_path_source(normalize_hash(options).merge("path" => path_relative_to_gemfile(path))), &blk) end def git(uri, options = {}, &blk) @@ -287,6 +286,10 @@ def normalize_options(name, version, opts) opts["git"] = @git_sources[git_name].call(opts[git_name]) end + if opts.key?("path") + opts["path"] = path_relative_to_gemfile(opts["path"]) + end + ["git", "path", "svn"].each do |type| if param = opts[type] if version.first && version.first =~ /^\s*=?\s*(\d[^\s]*)\s*$/ @@ -318,5 +321,10 @@ def normalize_source(source) raise GemfileError, "Unknown source '#{source}'" end end + + def path_relative_to_gemfile(path) + @gemfile ||= Bundler.default_gemfile + @gemfile.dirname + path + end end end