備忘録、はじめました。

作業したこと忘れないようにメモっておきます。

Erlangのバージョン管理ツール自作

前はkerlを使って複数バージョンを持ってたけど、buildのときのoption指定とかが思う感じに指定できなかったので自前で用意した話。

GitHub - tkyshm/erlch: Erlang version manager

やりたいことは、erlのバージョンを気軽に切り替えられることと、インストールの手間を1コマンドでできるようにすることです。

helpを使うと以下の感じで出てきます。

 erlch command list:

        help: display how to use erlch command.
         use: switches your erlang version.
       fetch: caches erlang versions for completions.
        list: lists your erlang versions.
     install: install erlang.
   uninstall: uninstall your installed erlang.

fetchコマンドはzshまたはbashのcompletionファイルを設定してもらった前提で使ってもらうと便利なものとなってます(ほとんど解説ないので結構不親切ですが…)。 fetchするとインストール可能なバージョンをtab補完できるようになります。ちなみに、バージョン情報はgithubのrepoのtagからとってきてます。

補完すると以下な感じです。

~/.erlch ❯❯❯ erlch install OTP
 -- available versions --
OTP-17.0                            OTP-17.5.6.3                        OTP-18.2.4.1                        OTP-19.1.4                          OTP_17.0-rc2                      
OTP-17.0.1                          OTP-17.5.6.4                        OTP-18.3                            OTP-19.1.5                          OTP_R13B03                        
OTP-17.0.2                          OTP-17.5.6.5                        OTP-18.3.1                          OTP-19.1.6                          OTP_R13B04                        
OTP-17.1                            OTP-17.5.6.6                        OTP-18.3.2                          OTP-19.1.6.1                        OTP_R14A                          
OTP-17.1.1                          OTP-17.5.6.7                        OTP-18.3.3                          OTP-19.2                            OTP_R14B                          
OTP-17.1.2                          OTP-17.5.6.8                        OTP-18.3.4                          OTP-19.2.1                          OTP_R14B01                        
OTP-17.2                            OTP-17.5.6.9                        OTP-18.3.4.1                        OTP-19.2.2                          OTP_R14B02                        
OTP-17.2.1                          OTP-18.0                            OTP-18.3.4.2                        OTP-19.2.3                          OTP_R14B03                        
OTP-17.2.2                          OTP-18.0-rc1                        OTP-18.3.4.3                        OTP-19.3                            OTP_R14B04                        
OTP-17.3                            OTP-18.0-rc2                        OTP-18.3.4.4                        OTP-19.3.1                          OTP_R15A                          
OTP-17.3.1                          OTP-18.0.1                          OTP-18.3.4.5                        OTP-19.3.2                          OTP_R15B                          
OTP-17.3.2                          OTP-18.0.2                          OTP-19.0                            OTP-19.3.3                          OTP_R15B01                        
OTP-17.3.3                          OTP-18.0.3                          OTP-19.0-rc1                        OTP-19.3.4                          OTP_R15B02                        
OTP-17.3.4                          OTP-18.1                            OTP-19.0-rc2                        OTP-19.3.5                          OTP_R15B03                        
OTP-17.4                            OTP-18.1.1                          OTP-19.0.1                          OTP-19.3.6                          OTP_R15B03-1                      
OTP-17.4.1                          OTP-18.1.2                          OTP-19.0.2                          OTP-19.3.6.1                        OTP_R16A_RELEASE_CANDIDATE        
OTP-17.5                            OTP-18.1.3                          OTP-19.0.3                          OTP-19.3.6.2                        OTP_R16B                          
OTP-17.5.1                          OTP-18.1.4                          OTP-19.0.4                          OTP-20.0                            OTP_R16B01                        
OTP-17.5.2                          OTP-18.1.5                          OTP-19.0.5                          OTP-20.0-rc1                        OTP_R16B01_RC1                    
OTP-17.5.3                          OTP-18.2                            OTP-19.0.6                          OTP-20.0-rc2                        OTP_R16B02                        
OTP-17.5.4                          OTP-18.2.1                          OTP-19.0.7                          OTP-20.0.1                          OTP_R16B03                        
OTP-17.5.5                          OTP-18.2.2                          OTP-19.1                            OTP-20.0.2                          OTP_R16B03-1                      
OTP-17.5.6                          OTP-18.2.3                          OTP-19.1.1                          OTP-20.0.3                          OTP_R16B03_yielding_binary_to_term
OTP-17.5.6.1                        OTP-18.2.4                          OTP-19.1.2                          OTP-20.0.4                                                            
OTP-17.5.6.2                        OTP-18.2.4.0.1                      OTP-19.1.3                          OTP_17.0-rc1    `

$HOME/.erlch 以下はこんな感じ。

~/.erlch ❯❯❯ tree -L 2 .
.
├── bin -> /home/tkyshm/.erlch/versions/20.0.4/bin
├── configure_opts
├── repo
│   └── otp
└── versions
    ├── 20.0
    └── 20.0.4

6 directories, 1 file

useを使ってバージョンを切り替えます。

~/.erlch ❯❯❯ erlch use 20.0
switched erlang version 20.0.

切り替えるとbinのシンボリックリンク先が変更されるだけです。なので、binのpathを通しておきます。