diff options
| author | Mike McQuaid | 2017-05-27 10:15:37 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2017-05-27 10:15:37 +0100 |
| commit | ef59a751f4ee904b4e713d1069a67ed9ee03b766 (patch) | |
| tree | 33f0738ebd8ab1c816590e86bd18cdf0f7b7e227 /Library/Homebrew/cmd | |
| parent | fb33acbbe47162adf90e92cbb6b244f26a5a346e (diff) | |
| download | brew-ef59a751f4ee904b4e713d1069a67ed9ee03b766.tar.bz2 | |
Improve some `brew install` messaging.
Improve the messaging around `brew install` when there's a possible user
action such as an `upgrade` or `link` and don't tell people to
`install --force` when it's unnecessary.
While I did this, tweak the output and function usage in a couple of
related places.
Some example output before this change:
```
Warning: openssl is a keg-only and another version is linked to opt.
Use `brew install --force` if you want to install this version
Warning: mysql@5.6 is a keg-only and another version is linked to opt.
Use `brew install --force` if you want to install this version
Warning: analog-6.0_1 already installed
Warning: bash-completion@2-2.5 already installed, it's just not linked.
```
Some example output after this change:
```
Error: openssl 1.0.2k is already installed
To upgrade to 1.0.2l, run `brew upgrade openssl`
Warning: mysql@5.6 5.6.36_1 is already installed
Warning: analog 6.0_1 is already installed
Warning: bash-completion@2 2.5 is already installed, it's just not linked.
You can use `brew link bash-completion@2` to link this version.
```
Diffstat (limited to 'Library/Homebrew/cmd')
| -rw-r--r-- | Library/Homebrew/cmd/install.rb | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 394b31db0..cc8750cad 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -146,8 +146,17 @@ module Homebrew # linked to opt, because installing without any warnings can break # dependencies. Therefore before performing other checks we need to be # sure --force flag is passed. - opoo "#{f.full_name} is a keg-only and another version is linked to opt." - puts "Use `brew install --force` if you want to install this version" + if f.outdated? + optlinked_version = Keg.for(f.opt_prefix).version + onoe <<-EOS.undent + #{f.full_name} #{optlinked_version} is already installed + To upgrade to #{f.version}, run `brew upgrade #{f.name}` + EOS + else + opoo <<-EOS.undent + #{f.full_name} #{f.pkg_version} is already installed + EOS + end elsif (ARGV.build_head? && new_head_installed) || prefix_installed # After we're sure that --force flag is passed for linked to opt # keg-only we need to be sure that the version we're attempting to @@ -159,30 +168,38 @@ module Homebrew f.pkg_version end - msg = "#{f.full_name}-#{installed_version} already installed" + msg = "#{f.full_name} #{installed_version} is already installed" linked_not_equals_installed = f.linked_version != installed_version if f.linked? && linked_not_equals_installed - msg << ", however linked version is #{f.linked_version}" - opoo msg - puts "You can use `brew switch #{f} #{installed_version}` to link this version." + msg = <<-EOS.undent + #{msg} + The currently linked version is #{f.linked_version} + You can use `brew switch #{f} #{installed_version}` to link this version. + EOS elsif !f.linked? || f.keg_only? - msg << ", it's just not linked." - opoo msg - else - opoo msg + msg = <<-EOS.undent + #{msg}, it's just not linked. + You can use `brew link #{f}` to link this version. + EOS end + opoo msg elsif !f.any_version_installed? && old_formula = f.old_installed_formulae.first - msg = "#{old_formula.full_name}-#{old_formula.installed_version} already installed" + msg = "#{old_formula.full_name} #{old_formula.installed_version} already installed" if !old_formula.linked? && !old_formula.keg_only? - msg << ", it's just not linked." + msg = <<-EOS.undent + #{msg}, it's just not linked. + You can use `brew link #{old_formula.full_name}` to link this version. + EOS end opoo msg elsif f.migration_needed? && !ARGV.force? # Check if the formula we try to install is the same as installed # but not migrated one. If --force passed then install anyway. - opoo "#{f.oldname} already installed, it's just not migrated" - puts "You can migrate formula with `brew migrate #{f}`" - puts "Or you can force install it with `brew install #{f} --force`" + opoo <<-EOS.undent + #{f.oldname} already installed, it's just not migrated + You can migrate formula with `brew migrate #{f}` + Or you can force install it with `brew install #{f} --force` + EOS else # If none of the above is true and the formula is linked, then # FormulaInstaller will handle this case. |
