kerl只有一個目標:讓我們在不同的OTP版本間隨意切換。他是一個純Bash項目。簡單實用的工作利器!
Readme里面用法已說明得非常清楚了。建議按流程來一次。
1.下載
安裝(一個bash腳本,根本就不用安裝~)
curl -O https://raw.githubusercontent.com/kerl/kerl/master/kerl&chmod a+x kerl
2.工作原理
從official Erlang website上得到所有的release包信息,然后再下載對應的release后安裝到指定的目錄下。你也可以使用KERL_BUILD_BACKEND=git
指定從official source code上下載源.
3.用法
./kerl kerl: build and install Erlang/OTP usage: ./kerl <command> [options ...] <command> Command to be executed Valid commands are: build Build specified release or git repository install Install the specified release at the given location deploy Deploy the specified installation to the given host and location update Update the list of available releases from your source provider list List releases, builds and installations delete Delete builds and installations active Print the path of the active installation plt Print Dialyzer PLT path for the active installation status Print available builds and installations prompt Print a string suitable for insertion in prompt cleanup Remove compilation artifacts (use after installation) version Print current version (current: 1.3.2)
3.1 列出所有可用的release包
$ ./kerl list releases R10B-0 R10B-10 R10B-1a R10B-2 R10B-3 R10B-4 R10B-5 R10B-6 R10B-7 R10B-8 R10B-9 R11B-0 R11B-1 R11B-2 R11B-3 R11B-4 R11B-5 R12B-0 R12B-1 R12B-2 R12B-3 R12B-4 R12B-5 R13A R13B01 R13B02-1 R13B02 R13B03 R13B04 R13B R14A R14B01 R14B02 R14B03 R14B04 R14B R14B_erts-5.8.1.1 R15B01 R15B02 R15B02_with_MSVCR100_installer_fix R15B03-1 R15B03 R15B R16A_RELEASE_CANDIDATE R16B01 R16B02 R16B03-1 R16B03 R16B 17.0-rc1 17.0-rc2 17.0 17.1 17.3 17.4 17.5 18.0 18.1 18.2 18.2.1 18.3 19.0 Run './kerl update releases' to update this list from erlang.org
3.2 下載指定release包並編譯
KERL_CONFIGURE_OPTIONS=--enable-hipe ./kerl build 19.0 19.0_hipe % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 184 100 184 0 0 132 0 0:00:01 0:00:01 --:--:-- 132 0 64.8M 0 51751 0 0 4277 0 4:25:04 0:00:12 4:24:52 10189
要從官網上下70M的東西,erlang.org對中國區本來就慢,建議使用git源(KERL_BUILD_BACKEND=git)
3.3 查看現在有release包列表
./kerl list builds
17.4 17.4 19.0 19.0_hipe
3.4 安裝包
$./kerl install 19.0_hipe /usr/local/sbin/erl_19_0_hipe Installing Erlang/OTP 19.0 (19.0) in /usr/local/sbin/erl_19_0... You can activate this installation running the following command: . /usr/local/sbin/erl_19_0/activate Later on, you can leave the installation typing: kerl_deactivate
稍等一會,就會提示你安裝成功。
3.5 使用指定版本的OTP
如果想在當前的shell中使用安裝好的上面19版本的OTP,只需要
$./usr/local/sbin/erl_19_0/activate
然后打開erlang shell試試看:
$erl Erlang/OTP 19 [erts-8.0] [source] [64-bit] [smp:4:4] [async-threads:10] [kernel-poll:false] Eshell V8.0 (abort with ^G) 1>
成功在當前的shell中使用19的release啦。
如果不想使用了,也可以使用下面命令來禁用
kerl_deactivate
以上就是kerl的基本用法,有了它,你就可以在本機上裝多個版本的erlang了。對要測試多個版本的工作太有用了。
4. 補充
可能有人也注意到了,這是從源碼重新編譯,可不可以更加方便的指定編譯的參數,
而不是像上面在命令行中 KERL_CONFIGURE_OPTIONS=--enable-hipe。
這是可以的。
kerl在home下有一個.kerlrc(類似於.bashrc),比如我的
emacs ~/.kerlrc KERL_CONFIGURE_OPTIONS="--disable-hipe --enable-smp-support --enable-threads --enable-kernel-poll --enable-darwin-64bit --with-ssl=/usr/local/Cellar/openssl/1.0.2h_1"
除了這個configure options外,還有很多項都可以在.kerlrc中配置(可以在readme中找到詳細的說明),方便又不缺乏靈活。
kerl在home下有一個.kerl(類似於.ssh目錄)
cd ~/.kerl && ls archives builds otp_builds otp_builds-e otp_installations otp_releases
這里就是kerl命令存放release和存install數據的地方。
5. 資源
5.1 elixir也有對應的項目叫kiex。
5.2 kerl甚至可以deploy到遠程的服務器上安裝,只要你配置好ssh key,雖然沒有用到,但是這也太炫酷啦。
5.3 basho使用kerl安裝的文檔:http://docs.basho.com/riak/kv/2.1.4/setup/installing/source/erlang/#kerl-prerequisites
If my fingers were erlang processes~