From c6142c76301ce2cb47c7751700586a56cfdda8b4 Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Sat, 24 Nov 2018 18:25:51 +0000 Subject: [PATCH] [Plugin] Ignore the deployment setting This allows installing plugins when the bundler is frozen, since plugins are not locked anyways --- lib/bundler/plugin.rb | 24 +++++++++++++----------- 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 422d4acfbca..996d29aafb7 100644 --- a/lib/bundler/plugin.rb +++ b/lib/bundler/plugin.rb @@ -73,20 +73,22 @@ def list # @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 3f8a5940fe6..29017c2afa1 100644 --- a/spec/plugins/install_spec.rb +++ b/spec/plugins/install_spec.rb @@ -191,6 +191,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