といろいろ重なったのでHomebrewを入れることにした。 Macでアプリの扱いが簡単な方がいいので、 /Applications ディレクトリに Homebrewをインストールすることにした。
参考:
Homebrew 本体のインストール
まず、あらかじめ
/opt/homebrewディレクトリを作成しておきます。cd /opt sudo mkdir homebrew sudo chown ${USER}:staff homebrew通常のインストールスクリプトを実行する代わりに、以下を実行します。 このコマンドは、Homebrew ドキュメントの Alternative Installs に書かれているものです。
curl -L https://github.com/Homebrew/homebrew/tarball/master | tar xz --strip 1 -C homebrewインストールそのものはこれだけです。 あとは実行パスの設定さえしてしまえば
brewコマンドが使えます。
これを /Applications ディレクトリに置き換えて行う。
まず /Applications/Homebrew を作成する。
mkdir /Applications/Homebrew
このディレクトリに Homebrew をインストールするので載っているコマンドを少し変更して実行する。
Homebrew (Legacy)
This repository was deprecated and split into two repositories:
- Homebrew formulae/packages: Homebrew/homebrew-core (former contents of
Library/Formula)- Homebrew package manager: Homebrew/brew
久しぶりに復旧作業を行ったら brew がインストールされなかった。リポジトリが非推奨になって上記の README.md しか存在しない状態になっていた。
Just extract (or
git clone) Homebrew wherever you want. Just avoid:
- Directories with names that contain spaces. Homebrew itself can handle spaces, but many build scripts cannot.
/tmpsubdirectories because Homebrew gets upset./swand/opt/localbecause build scripts get confused when Homebrew is there instead of Fink or MacPorts, respectively.However do yourself a favour and install to
/usr/local. Some things may not build when installed elsewhere. One of the reasons Homebrew just works relative to the competition is because we recommend installing to/usr/local. Pick another prefix at your peril!mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
URLを
https://github.com/Homebrew/brew/tarball/master
にしたら動きそうだ。
cd /Applications/Homebrew
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C .
上記の例では /opt/homebrew に、 /opt ディレクトリから展開を行っているので、 ディレクトリの移動等でパスを変えている。
$PATH の設定実行パスの設定
/usr/local/binと違ってデフォルトで実行パスが通っていないので、以下のどれかで設定します。
/etc/pathsに/opt/homebrew/binを追加。/etc/paths.d/homebrewというファイルを作って/opt/homebrew/binと記述。 (ただし、/etc/paths.d/*は/etc/pathsよりも後にパスが追加される点に注意)~/.zshrcや~/.bashrcでPATH環境変数を設定。キャッシュパスの設定
キャッシュの参照先が
/usr/localや/Library/Cachesになってしまうようなので、 パスを変更します。
~/.zshrcや~/.bashrcで以下を設定します。export HOMEBREW_CACHE=/opt/homebrew/cacheこの内容は、 コメント でご指摘いただいたものです。ありがとうございます。
HOMEBREW_CACHE- If set, instructs Homebrew to use the given directory as the download cache.
Default:
~/Library/Caches/Homebrew.
bash_profile に $PATH の設定を加える。
#XDG base directory specification
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_CACHE_HOME="$HOME/.cache"
#VimR command
export PATH="$PATH:/Applications/VimR.app/Contents/Resources"
#Homebrew command
export PATH="$PATH:/Applications/Homebrew/bin"
export HOMEBREW_CACHE="$XDG_CACHE_HOME/Homebrew"
export PATH="$PATH:/Applications/Homebrew/bin"brew へのパスを通しているexport HOMEBREW_CACHE="$XDG_CACHE_HOME/Homebrew"brew install sl
sl -l