Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def locked_gems
definition.locked_gems
elsif Bundler.default_lockfile.file?
lock = Bundler.read_file(Bundler.default_lockfile)
LockfileParser.new(lock)
LockfileParser.new(lock, Bundler.default_lockfile.dirname)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, opti

if lockfile && File.exist?(lockfile)
@lockfile_contents = Bundler.read_file(lockfile)
@locked_gems = LockfileParser.new(@lockfile_contents)
@locked_gems = LockfileParser.new(@lockfile_contents, lockfile.dirname)
@locked_platforms = @locked_gems.platforms
@platforms = @locked_platforms.dup
@locked_bundler_version = @locked_gems.bundler_version
Expand Down
5 changes: 3 additions & 2 deletions lib/bundler/lockfile_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def self.sections_to_ignore(base_version = nil)
attributes
end

def initialize(lockfile)
def initialize(lockfile, root_path)
@root_path = root_path
@platforms = []
@sources = []
@dependencies = {}
Expand Down Expand Up @@ -170,7 +171,7 @@ def parse_source(line)
end
when *SOURCE
@current_source = nil
@opts = {}
@opts = { "root_path" => @root_path }
@type = line
else
parse_spec(line)
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/lockfile_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@

describe "#initialize" do
before { allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app("gems.rb")) }
subject { described_class.new(lockfile_contents) }
subject { described_class.new(lockfile_contents, nil) }

let(:sources) do
[Bundler::Source::Git.new("uri" => "https://github.com/alloy/peiji-san.git", "revision" => "eca485d8dc95f12aaec1a434b49d295c7e91844b"),
Expand Down
21 changes: 21 additions & 0 deletions spec/commands/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -534,4 +534,25 @@
"setting them for authentication.")
end
end

describe "when sharing gemfile with path sources across different directories" do
it do
build_lib("foo", :path => "foo")
create_file("app/.bundle/config", <<-YAML)
---
BUNDLE_GEMFILE: "../Gemfile"
YAML
gemfile <<-RUBY
gem 'foo', :path => 'foo'
RUBY

bundle "install"
expect(out).to include("Bundle complete!")
in_app_root_custom "app" do
bundle "install"
expect(out).to include("Bundle complete!")
expect(the_bundle).to include_gem("foo 1.0")
end
end
end
end
8 changes: 4 additions & 4 deletions spec/commands/lock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ def read_lockfile(file = "Gemfile.lock")
it "supports adding new platforms" do
bundle! "lock --add-platform java x86-mingw32"

lockfile = Bundler::LockfileParser.new(read_lockfile)
lockfile = Bundler::LockfileParser.new(read_lockfile, nil)
expect(lockfile.platforms).to match_array(local_platforms.unshift(java, mingw).uniq)
end

it "supports adding the `ruby` platform" do
bundle! "lock --add-platform ruby"
lockfile = Bundler::LockfileParser.new(read_lockfile)
lockfile = Bundler::LockfileParser.new(read_lockfile, nil)
expect(lockfile.platforms).to match_array(local_platforms.unshift("ruby").uniq)
end

Expand All @@ -183,12 +183,12 @@ def read_lockfile(file = "Gemfile.lock")
it "allows removing platforms" do
bundle! "lock --add-platform java x86-mingw32"

lockfile = Bundler::LockfileParser.new(read_lockfile)
lockfile = Bundler::LockfileParser.new(read_lockfile, nil)
expect(lockfile.platforms).to match_array(local_platforms.unshift(java, mingw).uniq)

bundle! "lock --remove-platform java"

lockfile = Bundler::LockfileParser.new(read_lockfile)
lockfile = Bundler::LockfileParser.new(read_lockfile, nil)
expect(lockfile.platforms).to match_array(local_platforms.unshift(mingw).uniq)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/install/gemfile/ruby_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

RSpec.describe "ruby requirement" do
def locked_ruby_version
Bundler::RubyVersion.from_string(Bundler::LockfileParser.new(lockfile).ruby_version)
Bundler::RubyVersion.from_string(Bundler::LockfileParser.new(lockfile, nil).ruby_version)
end

# As discovered by https://github.com/bundler/bundler/issues/4147, there is
Expand Down
2 changes: 2 additions & 0 deletions spec/support/sometimes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def run_with_retries(example_to_run, retries)
end
end

RSpec::Support.require_rspec_core "formatters/console_codes"

RSpec.configure do |config|
config.include Sometimes
config.alias_example_to :sometimes, :sometimes => true
Expand Down
2 changes: 1 addition & 1 deletion spec/support/the_bundle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def lockfile

def locked_gems
raise "Cannot read lockfile if it doesn't exist" unless locked?
Bundler::LockfileParser.new(lockfile.read)
Bundler::LockfileParser.new(lockfile.read, lockfile.dirname)
end
end
end