Ruby ライクなプログラミング言語 crystal について勉強しています。
今回は「crenv」を入れてみたのでその時のメモを残します。
手順
crenv インストール
以下のコマンドを実行する前に、事前に anyenv をインストールしておく必要があります。
$ anyenv install crenv $ exec $SHELL -l $ crenv -v
利用できるバージョンを一覧表示
以下のコマンドで利用できるバージョンの一覧が表示されます。
$ crenv install -l Available versions: 0.5.0 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 0.5.8 0.5.9 0.5.10 0.6.0 0.6.1 0.7.0 0.7.1 0.7.2 0.7.3 0.7.4 0.7.5 0.7.6 0.7.7 0.8.0 0.9.0 0.9.1 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.12.0 0.13.0 0.14.0 0.14.1 0.14.2 0.15.0 0.16.0 0.17.0 0.17.1 0.17.2 0.17.3 0.17.4 0.18.0 0.18.2 0.18.4 0.18.6 0.18.7 0.19.0 0.19.1 0.19.2 0.19.3 0.19.4 0.20.0 0.20.1 0.20.3 0.20.4 0.20.5 0.21.0 0.21.1 0.22.0 0.23.0 0.23.1 0.24.0 0.24.1 0.24.2 0.25.0 0.25.1 0.26.0 0.26.1 0.27.0 0.27.1 0.27.2 0.28.0 0.29.0 0.30.0 0.30.1 0.31.0 0.31.1 0.32.0 0.32.1 0.33.0 0.34.0 0.35.0 0.35.1
crystal インストール
$ crenv install 0.19.0 Resolving Crystal download URL by Remote Cache ... ok Downloading Crystal binary tarball ... https://github.com/crystal-lang/crystal/releases/download/0.19.0/crystal-0.19.0-1-darwin-x86_64.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 641 100 641 0 0 1161 0 --:--:-- --:--:-- --:--:-- 1161 100 13.5M 100 13.5M 0 0 5095k 0 0:00:02 0:00:02 --:--:-- 7065k ok Moving the Crystal directory ...ok Checking if Shards already exists ... ng Resolving Shards download URL ... ok Downloading Shards tarball ... https://github.com/crystal-lang/shards/archive/v0.6.4.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 127 100 127 0 0 354 0 --:--:-- --:--:-- --:--:-- 354 100 26916 0 26916 0 0 35509 0 --:--:-- --:--:-- --:--:-- 134k ok Building Shards ... [warn] kq_init: detected broken kqueue; not using.: Undefined error: 0 ok Copying Shards binary ... ok Install successful
crystal バージョン確認
$ crenv versions * system (set by /Users/xxxxx/.anyenv/envs/crenv/version) 0.19.0
local に設定
$ crenv local 0.19.0
crystal バージョン確認
$ crystal -v Crystal 1.0.0 (2021-03-22) LLVM: 9.0.1 Default target: x86_64-apple-macosx
REPL もインストール
以下のコマンドで REPL もインストールします。
$ brew install crystal-icr
REPL は Read-Eval-Print Loopの略で、利用者が入力欄にキーボードなどから式や文を一行入力すると、即座に解釈・実行して結果を返し、再び入力可能になるもの。インタプリタの一種です。
icr 実行
icr コマンドで crystal の REPL を起動させます。
$ icr WARNING: ICR is not a full featured REPL. It works by building up a source file, compiling and re-running all of it on each input. That has side effects: * Current time and random numbers change retroactively * Files and network/database connections are reopened on every run * Running a sleep or benchmark will delay execution of next inputs * Unexpected behavior of fibers, channels, shell commands and maybe others Be careful while running your commands. You can disable this warning with --disable-usage-warning flag. icr(1.0.0) >