diff options
| author | Mike McQuaid | 2017-04-25 12:45:37 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2017-04-25 12:45:39 +0100 |
| commit | 18c2713df4a153ae815de9ca99e51ae8ed6aae28 (patch) | |
| tree | e1687c4f676c55868fdfa9ac97225fcca5d03a70 | |
| parent | a3b6cbe23d9fe27008c7610d3b0146200eee1195 (diff) | |
| download | brew-18c2713df4a153ae815de9ca99e51ae8ed6aae28.tar.bz2 | |
formula_installer: improve install/upgrade message
If you `brew install` a formula that's already installed you get:
Warning: ripgrep-0.5.1 already installed
If you `brew install` an outdated formula that's installed you get:
Error: ripgrep-0.5.1 already installed. To install this version, first
`brew unlink ripgrep`
Instead, suggest that the user should `brew upgrade` in this case. If
the formula isn't outdated use the previous message.
| -rw-r--r-- | Library/Homebrew/formula_installer.rb | 17 | ||||
| -rw-r--r-- | Library/Homebrew/test/cmd/install_spec.rb | 2 |
2 files changed, 14 insertions, 5 deletions
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 2153e7671..1d8346f13 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -217,11 +217,20 @@ class FormulaInstaller # function but after instantiating this class so that it can avoid having to # relink the active keg if possible (because it is slow). if formula.linked_keg.directory? - # some other version is already installed *and* linked - raise CannotInstallFormulaError, <<-EOS.undent - #{formula.name}-#{formula.linked_keg.resolved_path.basename} already installed - To install this version, first `brew unlink #{formula.name}` + message = <<-EOS.undent + #{formula.name} #{formula.linked_keg.resolved_path.basename} is already installed EOS + message += if formula.outdated? && !formula.head? + <<-EOS.undent + To upgrade to #{formula.version}, run `brew upgrade #{formula.name}` + EOS + else + # some other version is already installed *and* linked + <<-EOS.undent + To install #{formula.version}, first run `brew unlink #{formula.name}` + EOS + end + raise CannotInstallFormulaError, message end check_conflicts diff --git a/Library/Homebrew/test/cmd/install_spec.rb b/Library/Homebrew/test/cmd/install_spec.rb index 034bdd53f..b819c17be 100644 --- a/Library/Homebrew/test/cmd/install_spec.rb +++ b/Library/Homebrew/test/cmd/install_spec.rb @@ -77,7 +77,7 @@ describe "brew install", :integration_test do EOS expect { brew "install", "testball1" } - .to output(/first `brew unlink testball1`/).to_stderr + .to output(/`brew upgrade testball1`/).to_stderr .and not_to_output.to_stdout .and be_a_failure |
