0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

wsl2 で anyenvからasdfに乗り換える

Posted at

この記事は何?

wsl2環境において anyenvを使っていたのですが、asdfのほうが管理が楽そうだったので乗り換えたときのメモです。

手順

  1. anyenvのアンインストール
  2. asdfのインストール

anyenvのアンインストール

まずはanuenvによってインストールした環境を確認し、削除していきます。
ターミナルを開き、以下のコマンドを実行して、インストール済みの環境を確認します。

anyenv versions

以下のようにインストール済みの環境が表示されると思います。

nodenv:
* system (set by /home/xxxx/.anyenv/envs/nodenv/version)
pyenv:
  system
  3.9.5
  3.10.6
* 3.11.0 (set by /home/xxxx/.anyenv/envs/pyenv/version)

以下のコマンドで、インストール特定の環境を削除します。上記の内容ではpyenvとnodenvを削除します。

anyenv uninstall nodenv
anyenv uninstall pyenv

再度、以下のコマンドを実行して、特定のバージョンが削除されたことを確認します。
表示されなければOKです。

anyenv versions

最後に、シェルの設定ファイル(通常は ~/.bashrc や ~/.zshrc)を開き、anyenvの初期化に関連する行を削除します。

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

最後に、anyenv のインストールディレクトリを削除します。デフォルトでは ~/.anyenv です。

rm -rf ~/.anyenv

これで完了です。

asdfのインストール

公式の手順に沿ってインストールします。

以下はpython環境をインストールしたときのコマンドです。

git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.13.1

.bashrcに以下を追記します。

. "$HOME/.asdf/asdf.sh"
. "$HOME/.asdf/completions/asdf.bash"

bashrcを再読込し、以下コマンドを実行してasdfが実行できることを確認

asdf --version

pythonプラグインを追加して、インストールを確認

asdf install python 3.9.13
asdf list python

グローバルに使用できるバージョンを指定し、確認します。

asdf global python 3.9.13
asdf current
python -V
python

起動できていれば完了です。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?