-
Notifications
You must be signed in to change notification settings - Fork 891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Teach rustup to override the toolchain from a version file #1172
Conversation
This looks great to me. I don't have particularly strong opinions about where the override should go, other than setting a precedent for storing stuff in It does make me wonder whether it's worth in the future having rustup follow a similar configuration hierarchy to cargo. |
A general rule of thumb with Cargo is that you shouldn't version control |
This adds a .rust-version file similar to rbenv's .ruby-version. The form of toolchain supported here is limited to channel names, explicit versions, and optional archive dates.
I like the idea of naming it |
README.md
Outdated
|
||
The version file has lower precedence than all other methods of | ||
specifying the toolchain. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just clarifying, given that the file has lower precedence (i.e. it might not be obvious when it is not used), does rustup show
work as expected?
Is it worth re-stating:
To see the active toolchain use
rustup show
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, rustup show will indicate that .rust-version is in play. I will update the docs as you suggest.
Just for the sake of having said it, my personal preference would have been However, I understand that you may also want the code to be opinionated so it is harder to abuse this late or reduce feature requests which request to abuse this. Having said that, this look really good, thank you! |
Looks good. I’d even go with |
I second @SimonSapin's comment, let's not repeat the error of Travis' taste for hidden files. |
I think making this lowest precedence is going to leave people confused when they set an override some other way, and then try to use a |
When compiling in
|
Yeah, that is my main reasoning, but also parsing toml is presumably more expensive than loading the string, and this is on a path that is supposed to be fast (though is increasingly bloated). If there is ever strong demand for yet more local rustup config, we can always add it. Just more stuff... @nox The precedent for dotfiles here is pretty well established, by rbenv, by git, not travis particularly. That said, I also think having a hidden file control what toolchain is invoked is pretty magical, and if we don't use the name 'rust-version', following rbenv's precedent, then we might as well abandon all precedent and just name the file 'rust-toolchain'. Interleaving the 'override' / toolchain-file search is will require some major refactoring, but I'll look into it. I do think that arrangement sounds more difficult to explain in the documentation, though perhaps it's more intuitive. |
I'm still feeling bikesheddy about the name. Possibilities:
@steveklabnik likes |
I'm inclined to drop the dot from the name. |
I'm against I think I'd go without the dot. There's no need to hide what version of Rust you use. |
I do know of project maintainers which want to keep their top directory clean and small (not me), so having a hidden file as option will certainly help. I guess it'd be okay if |
Sounds like a minor annoyance to discourage you from using it. Or alternatively, a very obvious sign that you are doing something special. Both seem like features here. |
Ok now the file is called 'rust-toolchain' and the precedence is as described by @SimonSapin / @metajack, where the closest override to the cwd wins. |
091ee47
to
2f657df
Compare
Also interleave the directory override and rust-toolchain directory walk.
@bors r+ |
@bors r+ |
@bors asleep at the wheel. |
This adds a .rust-version file similar to rbenv's .ruby-version.
The form of toolchain supported here is limited to channel names,
explicit versions, and optional archive dates.
From the readme:
The version file
rustup
directory overrides are a local configuration, stored in$RUSTUP_HOME
. Some projects though find themselves 'pinned' to aspecific release of Rust and want this information reflected in their
source repository. This is most often the case for nightly-only
software that pins to a revision from the release archives.
In these cases the toolchain can be named in the project's directory
in a file called
.rust-version
, the content of which the name of asingle
rustup
toolchain, and which is suitable to check in to sourcecontrol.
The toolchains named in this file have a more restricted form than
rustup toolchains generally, and may only contain the names of the
three release channels, 'stable', 'beta', 'nightly', Rust version
numbers, like '1.0.0', and optionally an archive date, like
'nightly-2017-01-01'. They may not name custom toolchains, nor
host-specific toolchains.
The version file has lower precedence than all other methods of
specifying the toolchain.
Some observations and questions about the design:
The file is called
.rust-version
with precedent from rbenv. The contentsof this file though would better be described as a "rust release channel",
or "rustup toolchain". A better name might be
.rustup-toolchain
thoughthe acceptable values in the file are a subset of valid toolchain names.
One might reuse the
.cargo
directory for this, putting the file ine.g.
.cargo/rust-version
. This seems reasonable, and would establisha strong precent for tools reusing
.cargo
; it would go against therbenv precedent. It would also go against the existing rustup
precedent where rustup stores it's global state in its own
~/.rustup
folder - but note that I have some small desire to move
~/.rustup
into
~/.cargo/rustup
as a simplification.Opinions about the above?
This doesn't allow specifying the host triple, nor does it allow
custom toolchains.
The search semantics are based off of the current working directory, though
one might feasibly expect them to be based off of the Cargo.toml directory.
That is
cargo --manifest=foo/Cargo.toml
will not search infoo
. Existingoverrides have this limitation as well.
Fixes #460
cc @SimonSapin @Diggsey @alexcrichton @yazaddaruvala