diff options
author | Bundlerbot <bot@bundler.io> | 2018-11-24 22:34:25 +0000 |
---|---|---|
committer | Colby Swandale <me@colby.fyi> | 2019-04-01 22:15:15 +1100 |
commit | fbab11810635b6c0843446320e7902186c7c715c (patch) | |
tree | 7f87e2b532f068951761c6930464664d2451a29f | |
parent | 65df5e64e4eb67961c179b52a7bb1cc8e7398a0a (diff) | |
download | bundler-fbab11810635b6c0843446320e7902186c7c715c.tar.gz |
Merge #6805
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 07d22aebd892b1b0ee8e3829bec57abb13864981)
-rw-r--r-- | lib/bundler/plugin.rb | 24 | ||||
-rw-r--r-- | spec/plugins/install_spec.rb | 22 |
2 files changed, 35 insertions, 11 deletions
diff --git a/lib/bundler/plugin.rb b/lib/bundler/plugin.rb index 53f9806b73..2b783e16f6 100644 --- a/lib/bundler/plugin.rb +++ b/lib/bundler/plugin.rb @@ -53,20 +53,22 @@ module Bundler # @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]}" diff --git a/spec/plugins/install_spec.rb b/spec/plugins/install_spec.rb index 9304d78062..e70503fb18 100644 --- a/spec/plugins/install_spec.rb +++ b/spec/plugins/install_spec.rb @@ -173,6 +173,28 @@ RSpec.describe "bundler plugin install" do 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 |