社内で、ケント・ベックの「テスト駆動開発」を写経する会を立ち上げて、アドバイザーみたいなことをやることになった。良いコードを書くにはまだ及ばないが、酷いテストコードを直す経験ならちょっとしたものである(笑)。
とりあえず、参加メンバーはあまり普段コードを書かないような人(うちの社内はそういう人の方が多いのだ)になるだろうから、書籍と全く同じようにJavaで書く。もうホントに一字一句その通りにやるのが良いと思う。というわけで、スタートガイドのようなものをQiitaに書いた。
その一方で、私はJavaでやってもつまらないので、Rustでやってみることにする。Rustは2年前に社内の勉強会でちょっと触って以来だ。そのときに一度インストールはしたのだが、その後、Diskが飛んでいるのでまたインストールするところからのスタートである。
さて、こういう時は本家からスタートするに限る。
インストールのページを見に行くと
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
をやれと書いてある。homebrewでも入れられるけど、こっちとデフォルトで入るモノが違ったりするらしいので、公式に従うことにする。
> curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh info: downloading installer Welcome to Rust! This will download and install the official compiler for the Rust programming language, and its package manager, Cargo. It will add the cargo, rustc, rustup and other commands to Cargo's bin directory, located at: /Users/tambara/.cargo/bin This can be modified with the CARGO_HOME environment variable. Rustup metadata and toolchains will be installed into the Rustup home directory, located at: /Users/tambara/.rustup This can be modified with the RUSTUP_HOME environment variable. This path will then be added to your PATH environment variable by modifying the profile files located at: /Users/tambara/.profile /Users/tambara/.bash_profile You can uninstall at any time with rustup self uninstall and these changes will be reverted. Current installation options: default host triple: x86_64-apple-darwin default toolchain: stable profile: default modify PATH variable: yes 1) Proceed with installation (default) 2) Customize installation 3) Cancel installation > info: profile set to 'default' info: default host triple is x86_64-apple-darwin info: syncing channel updates for 'stable-x86_64-apple-darwin' info: latest update on 2020-03-12, rust version 1.42.0 (b8cedc004 2020-03-09) info: downloading component 'cargo' info: downloading component 'clippy' info: downloading component 'rust-docs' 12.1 MiB / 12.1 MiB (100 %) 11.7 MiB/s in 1s ETA: 0s info: downloading component 'rust-std' 16.1 MiB / 16.1 MiB (100 %) 8.2 MiB/s in 1s ETA: 0s info: downloading component 'rustc' 54.5 MiB / 54.5 MiB (100 %) 8.7 MiB/s in 6s ETA: 0s info: downloading component 'rustfmt' info: installing component 'cargo' info: installing component 'clippy' info: installing component 'rust-docs' 12.1 MiB / 12.1 MiB (100 %) 2.9 MiB/s in 3s ETA: 0s info: installing component 'rust-std' 16.1 MiB / 16.1 MiB (100 %) 14.9 MiB/s in 1s ETA: 0s info: installing component 'rustc' 54.5 MiB / 54.5 MiB (100 %) 8.7 MiB/s in 6s ETA: 0s info: installing component 'rustfmt' info: default toolchain set to 'stable' stable installed - rustc 1.42.0 (b8cedc004 2020-03-09) Rust is installed now. Great! To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH environment variable. Next time you log in this will be done automatically. To configure your current shell run source $HOME/.cargo/env
.profileにはちゃんとパスの設定も入っている。
> cat .profile export PATH="$HOME/.cargo/bin:$PATH"
が、こちらはfish遣いなので、自分でやる。
.config/fish/config.fishの末尾に
# Rust set -x PATH $HOME/.cargo/bin $PATH
を書き足せばOKだ。
> rustup --version rustup 1.21.1 (7832b2ebe 2019-12-20) > rustc --version rustc 1.42.0 (b8cedc004 2020-03-09) > cargo --version cargo 1.42.0 (86334295e 2020-01-31)
とりあえず、一安心。