Hello,
This question raised during setting up Travis CI for my little project.
I used recommendation from rustfmt repo
language: rust
before_script:
- rustup toolchain install nightly
- rustup component add --toolchain nightly rustfmt-preview
- which rustfmt || cargo install --force rustfmt-nightly
script:
- cargo +nightly fmt --all -- --write-mode=diff
- cargo build
- cargo test
I have noticed that which rustfmt
was always succeed.
I thought that it could be because of caching, but after clearing all caches nothing changed - rustfmt
was still "preinstalled".
Travis CI support team said to me
Although I'm not super familiar with Rust and its ecosystem, I had a look and it seems that
rustfmt
comes already pre-installed in the location you have referenced i.e. /home/travis/.cargo/bin/rustfmt.
Looks like I am not familiar either
I run empty Docker container locally, installed Rust nightly into it and saw that indeed rustfmt
was already there at ~/.cargo/bin/rustfmt
with the latest version
rustfmt -V
0.3.8-nightly (346238f 2018-02-04)
My question is how should I properly install rustfmt
?
Should I ever use cargo install rustfmt-nightly
?
Sometimes I occasionally got a warning
warning: tool
rustfmt
is already installed, remove it from~/.cargo/bin
, then runrustup update
to have rustup manage this tool.
What does it mean exactly and why I got it?
Looks like on Travis CI I could use rustfmt
which comes with the language since Rust is installed each time a new build is running.
And on my local machine I could cargo install [-f] rustfmt-nightly
to install and update it without updating Rust.
But I am not sure here.
Could you please help me to figure it out?
Thanks.