---
title: "topgradeでmacOSのupdate管理 | grasys blog"
url: "https://blog.grasys.io/post/yusukeh/topgrade/"
description: "こんにちは、grasysの長谷川です。 さっきそろそろmacbookのバッテリー寿命によりめんどくさくてずっと延期していた交換時期がくるので、mackupでmacOSのbackupという記事を書きました。 いきなり交換しなきゃいけない事態に備えて事前の確認なんですが、ほんとはこっちを書きたかった。 ちょっと前にrus…"
---

# topgradeでmacOSのupdate管理

-   ![](/_astro/noicon.CTHOhNiB_1HMs6A.webp)[yusukeh](/authors/yusukeh/)
-   公開日：2022年1月12日
-   カテゴリー：[Tech](/categories/tech/)
-   タグ：[#macOS](/tags/macos/)[#シリーズ: ターミナル環境](/tags/シリーズ-ターミナル環境/)[#topgrade](/tags/topgrade/)

![topgradeでmacOSのupdate管理](/_astro/ogp.BAkSGNpi_yC2xx.webp)

こんにちは、grasysの長谷川です。  
さっきそろそろmacbookのバッテリー寿命によりめんどくさくてずっと延期していた交換時期がくるので、[mackupでmacOSのbackup](https://blog.grasys.io/post/yusukeh/mackup/)という記事を書きました。 いきなり交換しなきゃいけない事態に備えて事前の確認なんですが、ほんとはこっちを書きたかった。

ちょっと前にrustで書かれたコマンドラインツール的な記事をみて、topgradeを見かけました。  
数年前（完全に忘れた）に触ったときは、あまり良いツールじゃなかったんですが、改めて触ってみるとこれがめちゃくちゃ良くなってる！！！👍  
久しぶりに感動したのでtopgradeについて書きます。

## topgrade

topgradeのgithubはこちら [topgrade: Upgrade averything](https://github.com/r-darwish/topgrade)

> Keeping your system up to date mostly involves invoking more than a single package manager. This usually results in big shell one-liners saved in your shell history. Topgrade tries to solve this problem by detecting which tools you use and run their appropriate package managers.

と書いてあるだけあって、実際動かしたけど対応がすさまじい😆

個人的には今まで[rerun](https://rerun.github.io/rerun/)というbash/zshのCommandline Framework的なものを使って、いろいろ管理してました。  
[brew](https://brew.sh/)とか[mas](https://github.com/mas-cli/mas)とかpipとかnpmとかrustupとかをrerunのcommand作ってブン回すみたいなことして管理してました。

だがしかし！今回それがまるっとtopgradeで解決しました！😁

## Installation

これも超絶簡単! [topgrade](https://github.com/r-darwish/topgrade#installation)のREADMEにも書いてありますがbrewで一発！🍺

Plain textcontent\_copy

```
brew install topgrade
```

## Usage

> Just run `topgrade`

って書いてあるだけある。めちゃくちゃシンプル！

## Step list

[Step list](https://github.com/r-darwish/topgrade/wiki/Step-list)をみるとわかるんだけど、  
対応がすげえ〜〜〜〜😂

まずいろんなOSに対応してる！！！！  
自分は元々Linuxだけでなくて、BSDとかSolarisとかも触ってきたおじさんなのですが、最近のUnix事情まで垣間見れてしまった・・・😅

WindowsなんてChocolateyやらScoopやらにも対応してるという、なんでもこいという状態なのがすげえ

## Customization

オリジナルのConfigはこんな感じ [topgrade/config.example.toml](https://github.com/r-darwish/topgrade/blob/develop/config.example.toml)  
[Customization](https://github.com/r-darwish/topgrade#customization)を見るとConfigration pathがあるのでそれを確認して修正します。

自分の変更点はこんな感じ

### disable

Plain textcontent\_copy

```
disable = ["shell"]
```

topgradeのshellはzshを指してるっぽい  
自分はおじさんなので、shellはいろいろ触ってきてるんですがここのところずっとbashのままです。  
bashrcを自動生成するscriptで管理しているんですが、それのzsh版を作っておらず・・・  
ちょっと諸事情によりzshに完全に移行しきれておらず・・・😅  
autenvでちょっとおかしくなっててshellをdisableにしちゃいました！  
あとでやるぞ！時間できたら！近いうち！

### git

Plain textcontent\_copy

```
[git]
repos = [
  "~/mac-cli",
  "~/mo",
  "~/rerun",
  "~/envutils-darwin"
]
```

[Mac CLI](https://github.com/guarinogabriel/Mac-CLI)や[Mustache](https://mustache.github.io/)とか[rerun](https://rerun.github.io/rerun/)とか・・・  
envutils-darwinは個人的なmac管理上やら業務上で使うscriptをrerunのmoduleとして構成してるリポジトリだったりをがばっと更新するためにこんな感じで追記

### Custom commands

Plain textcontent\_copy

```
[commands]
"/opt/homebrew/bin/brew bundle --force dump"
```

ここでやるべきかは違うな！  
でもばらばらコマンド叩きたくないので🤣 これ良くないな😂

## 実行

Plain textcontent\_copy

```
topgrade -n

―― 18:17:17 - Brew ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
Dry running: /usr/local/bin/brew update
Dry running: /usr/local/bin/brew upgrade --ignore-pinned --formula

―― 18:17:17 - Brew - Cask ――――――――――――――――――――――――――――――――――――――――――――――――――――――
Dry running: /usr/local/bin/brew cu -y

―― 18:17:20 - Git repositories ―――――――――――――――――――――――――――――――――――――――――――――――――
Would pull /Users/yusukeh/mac-cli
Would pull /Users/yusukeh/envutils-darwin
Would pull /Users/yusukeh/mo
Would pull /Users/yusukeh/rerun

―― 18:17:20 - TLDR ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
Dry running: /usr/local/opt/tldr/bin/tldr --update

―― 18:17:20 - rustup ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
Dry running: /Users/yusukeh/rustup/rust/bin/rustup self update
Dry running: /Users/yusukeh/rustup/rust/bin/rustup update

―― 18:17:20 - Cargo ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
Dry running: /Users/yusukeh/rustup/rust/bin/cargo-install-update install-update --git --all

―― 18:17:20 - pip3 ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
Dry running: /usr/local/opt/python/bin/pip3 install --upgrade --user pip

―― 18:17:20 - Node Package Manager ―――――――――――――――――――――――――――――――――――――――――――――
Dry running: /Users/yusukeh/nodenv/shims/npm update -g

―― 18:17:20 - Performant Node Package Manager ――――――――――――――――――――――――――――――――――
Dry running: /Users/yusukeh/nodenv/shims/pnpm update -g

―― 18:17:20 - RubyGems ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――
Dry running: /usr/bin/gem update --user-install

―― 18:17:20 - gcloud ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
Dry running: /Users/yusukeh/google-cloud-sdk/bin/gcloud components update --quiet

―― 18:17:20 - brew file ――――――――――――――――――――――――――――――――――――――――――――――――――――――――
Dry running: /bin/bash -c /usr/local/bin/brew file init -f ${HOMEBREW_BREWFILE} -b ${HOMEBREW_BREWFILE_BACKUP}

―― 18:17:20 - macOS App Store ――――――――――――――――――――――――――――――――――――――――――――――――――
Dry running: /usr/local/opt/mas/bin/mas upgrade

―― 18:17:20 - macOS system update ――――――――――――――――――――――――――――――――――――――――――――――
Finding available software
No new software available.

―― 18:17:27 - Summary ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
Brew (Intel): OK
Brew Cask (Intel): OK
Git repositories: OK
TLDR: OK
rustup: OK
cargo: OK
pip3: OK
npm: OK
pnpm: OK
gem: OK
gcloud: OK
brew file: OK
App Store: OK
System upgrade: OK
```

汚れるのでここではdry-runのoutputを貼り付けてるけど、やばい！神！最高！  
かゆいところがなんかスッキリ（npmとpnpmがちょっとあれだけど、CLIツール使ってるだけだし、使う方だけ残してdisableした方がいいかな）

## 感想

極力、楽にやりたいって観点ですごく良い  
個人的には大好き！

手元のmacbookだけなので今回は試してないけど、  
[Remote Execution](https://github.com/r-darwish/topgrade#remote-execution)って項目があって、configにもsshのパラメータあったりとかするので、リモートホストもサクッとやれるんだろうな  
ちょっとお仕事で利用してるサーバとかには仕込みにくいけど、仕事から隔離された開発環境のサーバとかラズパイとかなら試してみてもいいかもなぁ  
でもまあ、linuxのremoteがとかより、そもそもmacが楽にやれるからそれだけでオレは幸せ！😁

## この記事を書いた人

[![](/_astro/yusukeh.BvUd2yKE_1mQ6Fp.webp)](/authors/yusukeh/)

### [yusukeh](/authors/yusukeh/)

Fly high. Think deep. Move fast. Go far.🦅

-   [X](https://x.com/yusukeh "X")
-   [GitHub](https://github.com/yusukeh "GitHub")
-   [Medium](https://medium.com/@yusukeh "Medium")
-   [Facebook](https://www.facebook.com/yusuke.exzm "Facebook")
-   [Instagram](https://www.instagram.com/yusukehasegawa/ "Instagram")
-   [LinkedIn](https://www.linkedin.com/in/hasegawa-yusuke-091b4164/ "LinkedIn")

[プロフィールと記事一覧](/authors/yusukeh/)
