# Control Rust Version with Rust-ToolChain

**URL:** <https://travis-ci.community/t/control-rust-version-with-rust-toolchain/12458>\
**Category:** Environments\
**Tags:** rust\
**Created:** [December 8, 2021, 4:53am UTC](https://travis-ci.community/t/control-rust-version-with-rust-toolchain/12458 "2021-12-08T04:53:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SolarUltima](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/solarultima/32/4019_2.png) [@SolarUltima](https://travis-ci.community/u/SolarUltima)\
**Post date:** [December 8, 2021, 4:53am UTC](https://travis-ci.community/t/control-rust-version-with-rust-toolchain/12458/1 "2021-12-08T04:53:26Z")

</div>

my company is working on a big rust project, and this project has a `rust-toolchain` file which tells rustup which exact nightly version to use. Unfortunately, Travis downloads and install the `nightly` Rust channel before rustup notices that we really need `nightly-2018-08-14` , so Rust is downloaded and installed twice. This is not only a waste of bandwidth, it currently also makes the builds noticeably slower.

I tried fixing this by setting `TRAVIS_RUST_VERSION` in `before_install` , but that already seems to be too late.

any idea on how to fix this??

---

<div class="post-metadata">

**Author:** ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)\
**Post date:** [December 8, 2021, 4:57am UTC](https://travis-ci.community/t/control-rust-version-with-rust-toolchain/12458/2 "2021-12-08T04:57:49Z")

</div>

I should mention that inspecting the content of `rust-toolchain` file is not ideal, since Travis only fetches `.travis.yml` instructions during the build configuration.

You can set this with `rust`, which is passed on to `--default-toolchain=` argument for `rustup`. For example:

```auto
language: rust
rust:
  - nightly-*

```

So `rustc --version` yields:

```bash
rustc --version
rustc (version)

```

---

<div class="post-metadata">

**Author:** ![SolarUltima](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/solarultima/32/4019_2.png) [@SolarUltima](https://travis-ci.community/u/SolarUltima)\
**Post date:** [December 8, 2021, 6:01pm UTC](https://travis-ci.community/t/control-rust-version-with-rust-toolchain/12458/3 "2021-12-08T18:01:59Z")

</div>

thank you, cant believe it took this long to find! thank u @montana

---

<div class="post-metadata">

**Author:** ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)\
**Post date:** [December 8, 2021, 6:14pm UTC](https://travis-ci.community/t/control-rust-version-with-rust-toolchain/12458/4 "2021-12-08T18:14:27Z")

</div>

Glad to hear it.
