Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What is going on with this article?
@m-masaki72

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

More than 1 year has passed since last update.

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みたいなオプションを実装する予定はないみたい

0
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
0
Help us understand the problem. What is going on with this article?