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

Commit

Permalink
Merge #6805
Browse files Browse the repository at this point in the history
6805: [Plugin] Ignore the deployment setting r=colby-swandale a=segiddins

### What was the end-user problem that led to this PR?

The problem was installing a new plugin in deployment mode would fail with a suggestion the lock file was corrupted, when it installed fine without deployment mode.

Fixes #6795.

### What was your diagnosis of the problem?

My diagnosis was deployment mode was interfering with installing a new plugin.

### What is your fix for the problem, implemented in this PR?

My fix overrides the deployment and frozen settings when creating the plugin Definition.

### Why did you choose this fix out of the possible options?

I chose this fix because having a "frozen" plugin bundle makes no sense, since plugins aren't written to the lockfile.

Co-authored-by: Samuel Giddins <segiddins@segiddins.me>
(cherry picked from commit 07d22ae)
  • Loading branch information
bundlerbot authored and colby-swandale committed Apr 1, 2019
1 parent 65df5e6 commit fbab118
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
24 changes: 13 additions & 11 deletions lib/bundler/plugin.rb
Expand Up @@ -53,20 +53,22 @@ def install(names, options)
# @param [Pathname] gemfile path
# @param [Proc] block that can be evaluated for (inline) Gemfile
def gemfile_install(gemfile = nil, &inline)
builder = DSL.new
if block_given?
builder.instance_eval(&inline)
else
builder.eval_gemfile(gemfile)
end
definition = builder.to_definition(nil, true)
Bundler.settings.temporary(:frozen => false, :deployment => false) do
builder = DSL.new
if block_given?
builder.instance_eval(&inline)
else
builder.eval_gemfile(gemfile)
end
definition = builder.to_definition(nil, true)

return if definition.dependencies.empty?
return if definition.dependencies.empty?

plugins = definition.dependencies.map(&:name).reject {|p| index.installed? p }
installed_specs = Installer.new.install_definition(definition)
plugins = definition.dependencies.map(&:name).reject {|p| index.installed? p }
installed_specs = Installer.new.install_definition(definition)

save_plugins plugins, installed_specs, builder.inferred_plugins
save_plugins plugins, installed_specs, builder.inferred_plugins
end
rescue RuntimeError => e
unless e.is_a?(GemfileError)
Bundler.ui.error "Failed to install plugin: #{e.message}\n #{e.backtrace[0]}"
Expand Down
22 changes: 22 additions & 0 deletions spec/plugins/install_spec.rb
Expand Up @@ -173,6 +173,28 @@ def exec(command, args)
expect(out).to include("Installed plugin ga-plugin")
plugin_should_be_installed("ga-plugin")
end

context "in deployment mode" do
it "installs plugins" do
install_gemfile! <<-G
source 'file://#{gem_repo2}'
gem 'rack', "1.0.0"
G

install_gemfile! <<-G, forgotten_command_line_options(:deployment => true)
source 'file://#{gem_repo2}'
plugin 'foo'
gem 'rack', "1.0.0"
G

expect(out).to include("Installed plugin foo")

expect(out).to include("Bundle complete!")

expect(the_bundle).to include_gems("rack 1.0.0")
plugin_should_be_installed("foo")
end
end
end

context "inline gemfiles" do
Expand Down

0 comments on commit fbab118

Please sign in to comment.