Skip to content

Commit

Permalink
[WIP] ✨ add "[Homebrew] brew bundleで環境構築を統一する"
Browse files Browse the repository at this point in the history
  • Loading branch information
murnana committed Nov 19, 2023
1 parent 38b6173 commit 37b66a0
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions articles/homebrew-brewfile-by-murnana.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
title: "[Homebrew] brew bundleで環境構築を統一する"
emoji: "📦"
type: "tech" # tech: 技術記事 / idea: アイデア
topics: ["homebrew", "mac"]
published: false
---

# 使い方 (プロジェクト単位の場合)

## 1. Homebrewをインストール
```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```


## 2. _Brewfile_ を作成したいディレクトリに移動

コマンドを実行する前に移動を行います。

例えばリポジトリ単位の場合は、リポジトリのルートディレクトリに移動します。
仮に、 `<プロジェクトのルートディレクトリのパス>` とすると
```bash
cd <プロジェクトのルートディレクトリのパス>
```


## 3. _Brewfile_ を作成

_Brewfile_ を作成するコマンドを打ちます。
```bash
brew dump
```


## 4. 作成された _Brewfile_ を編集

`brew dump` は、現在の環境にあるものをリストアップします
そのため内容を編集し、必要な分だけ記載するようにします。

ファイルは _<プロジェクトのルートディレクトリのパス>/Brewfile_ にあります。


## 5. _Brewfile_ 内に記載されたパッケージをロック

_Brewfile_ だけだと、別の環境でバージョンを合わせるのが難しくなります。
そのため、_Brewfile.lock.json_ を生成します。

生成するためのコマンドは以下になります。
```bash
brew install --no-upgrade
```



# 参考

- [macOS(またはLinux)用パッケージマネージャー — Homebrew](https://brew.sh/index_ja)
- [brew(1) – The Missing Package Manager for macOS (or Linux) — Homebrew Documentation](https://docs.brew.sh/Manpage#bundle-subcommand) _- bundle -_
- [Homebrew/homebrew-bundle: 📦 Bundler for non-Ruby dependencies from Homebrew, Homebrew Cask and the Mac App Store.](https://github.com/Homebrew/homebrew-bundle#usage)
- [Macの開発環境構築を自動化する 2019年夏版 - karakaram-blog](https://www.karakaram.com/how-to-automate-your-mac-set-up/)

0 comments on commit 37b66a0

Please sign in to comment.