diff options
author | Homu <homu@barosl.com> | 2016-02-16 08:57:47 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-02-16 08:57:47 +0900 |
commit | 9a20a1e5d80c44f2532228dc3c9a03d244de045b (patch) | |
tree | a5c814ab41a809124cb0cc809e590d79cca5947e | |
parent | 6678cd7320af97a07a1777c3c994862f017a748b (diff) | |
parent | 32b641ad34e7f5ebc92c52f436fd449c95fdde86 (diff) | |
download | bundler-9a20a1e5d80c44f2532228dc3c9a03d244de045b.tar.gz |
Auto merge of #4301 - RochesterinNYC:better-ux-message-for-bundle-outdated-after-deployment, r=segiddins
Add error with message/explanation for `bundle outdated` in a frozen state
Adds a helpful error message for when you run `bundle outdated` after having run `bundle install --deployment`.
```
You are trying to check outdated gems in deployment mode. Run `bundle outdated` elsewhere.
If this is a development machine, remove the /path/to/Gemfile freeze
by running `bundle install --no-deployment`.
```
- closes #4287
-rw-r--r-- | lib/bundler/cli/outdated.rb | 14 | ||||
-rw-r--r-- | spec/commands/outdated_spec.rb | 22 |
2 files changed, 36 insertions, 0 deletions
diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index f2354465be..1535b2c4bf 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -10,6 +10,8 @@ module Bundler end def run + check_for_deployment_mode + sources = Array(options[:source]) gems.each do |gem_name| @@ -109,5 +111,17 @@ module Bundler exit 1 end end + + private + + def check_for_deployment_mode + if Bundler.settings[:frozen] + error_message = "You are trying to check outdated gems in deployment mode. " \ + "Run `bundle outdated` elsewhere.\n" \ + "\nIf this is a development machine, remove the #{Bundler.default_gemfile} freeze" \ + "\nby running `bundle install --no-deployment`." + raise ProductionError, error_message + end + end end end diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb index dcdb21ae66..b4895659db 100644 --- a/spec/commands/outdated_spec.rb +++ b/spec/commands/outdated_spec.rb @@ -273,4 +273,26 @@ describe "bundle outdated" do expect(out).to include("weakling (newest") end end + + context "after bundle install --deployment" do + before do + install_gemfile <<-G, :deployment => true + source "file://#{gem_repo2}" + + gem "rack" + gem "foo" + G + end + + it "outputs a helpful message about being in deployment mode" do + update_repo2 { build_gem "activesupport", "3.0" } + + bundle "outdated" + expect(exitstatus).to_not be_zero if exitstatus + expect(out).to include("You are trying to check outdated gems in deployment mode.") + expect(out).to include("Run `bundle outdated` elsewhere.") + expect(out).to include("If this is a development machine, remove the ") + expect(out).to include("Gemfile freeze\nby running `bundle install --no-deployment`.") + end + end end |