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.
This commit is contained in:
parent
a3b6cbe23d
commit
18c2713df4
@ -217,11 +217,20 @@ class FormulaInstaller
|
|||||||
# function but after instantiating this class so that it can avoid having to
|
# function but after instantiating this class so that it can avoid having to
|
||||||
# relink the active keg if possible (because it is slow).
|
# relink the active keg if possible (because it is slow).
|
||||||
if formula.linked_keg.directory?
|
if formula.linked_keg.directory?
|
||||||
# some other version is already installed *and* linked
|
message = <<-EOS.undent
|
||||||
raise CannotInstallFormulaError, <<-EOS.undent
|
#{formula.name} #{formula.linked_keg.resolved_path.basename} is already installed
|
||||||
#{formula.name}-#{formula.linked_keg.resolved_path.basename} already installed
|
|
||||||
To install this version, first `brew unlink #{formula.name}`
|
|
||||||
EOS
|
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
|
end
|
||||||
|
|
||||||
check_conflicts
|
check_conflicts
|
||||||
|
|||||||
@ -77,7 +77,7 @@ describe "brew install", :integration_test do
|
|||||||
EOS
|
EOS
|
||||||
|
|
||||||
expect { brew "install", "testball1" }
|
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 not_to_output.to_stdout
|
||||||
.and be_a_failure
|
.and be_a_failure
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user