1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Error: formula x.x is already installed To upgrade to x.x.x , run `brew upgrade formula`.

Last updated at Posted at 2020-02-20

brew update と set -e を一緒に使っていて処理が止まった

開発環境セットアップにて, set -e を使っていると,brew installの部分で処理が止まった.
よく観察してみると,brew updateにて既存のアップデートがある場合にはerrorで返すことが見られた.

状況

intialSetup.sh
set -e
brew install formula # 表題の出力とともにここで止まる.
echo  # brew install でエラー終了することにより実行されないことがある.

落ち着いた解法

packageがあるかどうかを確認してupgradeする.

if brew ls --versions ${formula} ; then 
  brew upgrade ${formula}
else
  brew install ${formula}
fi

コミュニティで報告されていた解法

エラー出力を捨てる.

brew install ${formula} 2>/dev/null && true

installだけ set +e 解除する

set +e
brew install ${formula}
set -e

参考

https://github.com/Homebrew/brew/issues/2491
brew側では,upgrade-if-installedみたいなオプションを実装する予定はないみたい

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?