LoginSignup
10
9

More than 5 years have passed since last update.

anyenvを導入して、既存のpyenv, rbenv, jenvも読み込めるようにsymlinkを貼った

Last updated at Posted at 2017-05-29

rbenvやpyenvを使っている人は多いと思いますが、それぞれインストールしていくと、.bashrcや.zshrcに書く内容が少しずつ増えていきますよね。
anyenvを使うと、書くべきはたったの2行で済みます。

export PATH="$HOME/.anyenv/bin:$PATH"
eval "$(anyenv init -)"

便利ですね。今回はコレを入れます。

1. anyenvのインストール

$ git clone https://github.com/riywo/anyenv ~/.anyenv

.zshrcを編集します。もしbashを使っているなら .bashrc.bash_profileなどになるでしょう。

export PATH="$HOME/.anyenv/bin:$PATH"
eval "$(anyenv init -)"

#今まで書いていたコメントアウトしてもよくなります↓

# Ruby Env
#export PATH="$HOME/.rbenv/bin:$PATH"
#eval "$(rbenv init -)"

# Python Env
# export PATH=$PYENV_ROOT/bin:$PATH
# eval "$(pyenv init -)"
# eval "$(pyenv virtualenv-init -)"

# Java Env
#export PATH="$HOME/.jenv/bin:$PATH"
#eval "$(jenv init -)"

シェルを再起動します。

$ exec $SHELL -l

anyenvが使えるか試してみます。

$ anyenv
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

お、もう使えるようです。

2. 新しく〇〇envを使いたいときは

新しくenv系をインストールしたいときはコマンド一つで簡単に入れることができます。例えば、ndenvを入れたいと思ったら、以下のようにします。

$ anyenv install ndenv

これだけで、もうすぐにndenvが使えます。便利〜。

$ ndenv
ndenv 0.4.0-4-ga339097
Usage: ndenv <command> [<args>]

Some useful ndenv commands are:
   commands    List all available ndenv commands
   local       Set or show the local application-specific Node version
   global      Set or show the global Node version
   shell       Set or show the shell-specific Node version
   install     Install a Node version using the node-build plugin
   uninstall   Uninstall a specific Node version
   rehash      Rehash ndenv shims (run this after installing executables)
   version     Show the current Node version and its origin
   versions    List all Node versions available to ndenv
   which       Display the full path to an executable
   whence      List all Node versions that contain the given executable

See `ndenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/riywo/ndenv#readme

3. 既にrbenv, pyenv, jenvなどを使っていた人向け

すでに、pyenvやrbenvなど、使っていたものがある場合は、symbolic linkを貼ってあげないと読み込んでくれないので貼ります。

$ ln -s ~/.rbenv ~/.anyenv/envs/rbenv
$ ln -s ~/.pyenv ~/.anyenv/envs/pyenv
$ ln -s ~/.jenv ~/.anyenv/envs/jenv

簡単でした。終わり。

参考にしたのはこちらの記事です。
http://qiita.com/luckypool/items/f1e756e9d3e9786ad9ea
http://d.hatena.ne.jp/riocampos+tech/20141019/install_anyenv

10
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
9