Mac に anyenv をインストール
概要
1 台の Mac で複数のプログラミング言語をインストールし、かつ、複数バージョンを切り替えながら使う、といったユースケースは、よくあると思います。そうなると rbenv やら ndenv やら、言語ごとに、なんとか env が増えて、その度に .bash_profile にパスの設定をしなければならなくなります。
そんな時は、anyenv を入れておけば、1 度だけ、.bash_profile にパス設定をしておけば OK です!
この記事の目次
参考サイト
- GitHub - anyenv/anyenv: All in one for **env
- anyenvやrbenvのpluginsの更新などをしやすくするプラグインを作った - @znz blog
- GitHub - znz/anyenv-update: anyenv plugin that provides `anyenv update` command to update all **env and all plugins
- GitHub - znz/anyenv-git: anyenv plugin that provides `anyenv git` command to run `git` in directories of all **env and all plugins
ホスト
Mac
- MacBook Pro ( 13-inch, Early 2011 ) 魔改造済み
anyenv インストール
Git でクローンするだけです。ターミナルを開いて、以下のコマンドでを実行してください。
% git clone https://github.com/riywo/anyenv ~/.anyenv
パスを通す
.bash_profile の編集
以下の 2 行のコマンドを実行し、 anyenv 用のパス設定を .bash_profile に追加します。
% echo 'export PATH="$HOME/.anyenv/bin:$PATH"' >> ~/.bash_profile % echo 'eval "$(anyenv init -)"' >> ~/.bash_profile
シェルの再起動
設定内容を反映させるため、以下のいずれかのコマンドを実行し、シェルを再起動します。
% exec $SHELL -l
or
% source ~/.bash_profile
確認
以下のコマンドを実行して、anyenv が動くかどうか確認します。
% anyenv
以下のような表示が出てくれば OK です。
anyenv Usage: anyenv <command> [<args>] Some useful anyenv commands are: commands List all available anyenv commands local Show the local application-specific Any version global Show the global Any version install Install a **env uninstall Uninstall a specific **anv version Show the current Any version and its origin versions List all Any versions available to **env See `anyenv help <command>' for information on a specific command. For full documentation, see: https://github.com/riywo/anyenv#readme
anyenv-update インストール
プラグイン用のディレクトリを作る
anyenv を使ってインストールした、なんとか env を一括でアップデートするためのプラグイン「 anyenv-update 」をインストールしておくと便利です。まずは、インストール先となるディレクトリを作成しましょう。
ターミナルで以下のコマンドを実行します。
% mkdir -p $(anyenv root)/plugins
インストール
Git でクローンします。
% git clone https://github.com/znz/anyenv-update.git $(anyenv root)/plugins/anyenv-update
確認
正常に稼働するかどうか、確認します。
% anyenv update
以下のような表示が出てくれば OK です。
Updating 'anyenv'... Updating 'anyenv/anyenv-update'...
以上となります。