概要
Qiita の「質問」を見ている中で、asdf というツールが存在するようだったので使用してみた.
本記事はその記録である.
asdf とは
asdf is a CLI tool that can manage multiple language runtime versions on a per-project basis. It is like gvm, nvm, rbenv & pyenv (and more) all in one! Simply install your language's plugin!
https://github.com/asdf-vm/asdf#asdf--
asdfはrubyやnodeなどの各種プログラミング言語に加え、kubectlやterraformなどの多種多様なツールのバージョン管理を行うことができるCLIツールです。
https://dev.icare.jpn.com/dev_cat/how_to_use_asdf/
実行環境
環境は次の通り
Ubuntu 18.04
bash
インストール
公式手順だと asdf_version が無い、とか色々と環境変数の有効化に失敗したので、公式手順では無い手順で実施した.
asdf を使って Python 3.10.4 を導入してみる
1. 最新を取得する
$ git clone https://github.com/asdf-vm/asdf.git ~/.asdf
2. 環境変数を有効化する
$ source ~/.asdf/asdf.sh
3. python 用プラグインを追加する
$ asdf plugin-add python
initializing plugin repository...Cloning into '/home/foo/.asdf/repository'...
remote: Enumerating objects: 3796, done.
remote: Counting objects: 100% (990/990), done.
remote: Compressing objects: 100% (510/510), done.
remote: Total 3796 (delta 587), reused 855 (delta 475), pack-reused 2806
Receiving objects: 100% (3796/3796), 875.58 KiB | 11.67 MiB/s, done.
Resolving deltas: 100% (1950/1950), done.
4. python 3.10.4 は導入可能か調べる
$ asdf list-all python |grep -w 10
:
3.10.4
:
5. Python 3.10.4 をインストールする
$ asdf install python 3.10.4
python-build 3.10.4 /home/foo/.asdf/installs/python/3.10.4
Downloading Python-3.10.4.tar.xz...
-> https://www.python.org/ftp/python/3.10.4/Python-3.10.4.tar.xz
Installing Python-3.10.4...
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
Installed Python-3.10.4 to /home/foo/.asdf/installs/python/3.10.4
6. Python 3.10.4 を有効にする
$ asdf global python 3.10.4
$ python --version
Python 3.10.4
$ asdf current python
python 3.10.4 /home/foo/.tool-versions
その他
asdf で有効化した Python 3.10.4 を使わないようにする方法 ... 不明
正式手順不明.
とりあえず $PATH
から $HOME/.asdf
関連を消して再設定すれば良いだろう.