Rustup: Unable to install rustfmt for a custom toolchain

Created on 12 Dec 2019  路  9Comments  路  Source: rust-lang/rustup

Problem
I'm building a custom rust toolchain to support bitcode under iOS using the scripts from: https://github.com/cowpaths/rust-bitcode/tree/fs-nightly-2019-09-05-llvm8 (which is a slightly modified fork of https://github.com/getditto/rust-bitcode )

The toolchain was installed using the command:

rustup toolchain link fs-2019-09-05-llvm8 ~/.fs-rust/toolchain-fs-2019-09-05-llvm8
rustup default fs-2019-09-05-llvm8

and everything seems to be fine. I can compile for iOS and for macosx using cargo build and cargo run. Now I'd like to install rustfmt. When I try:

rustup component add rustfmt

I get the following output:

error: toolchain 'fs-2019-09-05-llvm8' does not support components
error: caused by: invalid toolchain name: 'fs-2019-09-05-llvm8'

So my question is, what do I need to do to install rustfmt (and the next thing woul;d be clippy).

Steps
See above

Notes

Output of rustup --version:
rustup 1.20.2+125 (5f6317e9f 2019-12-03)

Output of rustup show:

Default host: x86_64-apple-darwin
rustup home:  /Users/davehylands/.rustup

installed toolchains
--------------------

stable-x86_64-apple-darwin
nightly-2019-09-05-x86_64-apple-darwin
nightly-2019-09-13-x86_64-apple-darwin
nightly-x86_64-apple-darwin
fs-2019-09-05-llvm8 (default)
ios-arm64
1.37.0-x86_64-apple-darwin
1.38.0-x86_64-apple-darwin

active toolchain
----------------

fs-2019-09-05-llvm8 (default)
rustc 1.39.0-dev
bug

All 9 comments

rustfmt shares parts of the compiler and as such would not be able to be installed in this manner. If you want rustfmt as part of your built toolchain, you should build it with x.py I believe.

You can, if you want, temporarily use another toolchain to format your code (e.g. by means of cargo +nightly fmt)

Given the above, if you still want rustup component add rustfmt to work, what would you actually expect it to do?

Well, I guess what I'm really asking is what do I need to do to make rustfmt work with my custom toolchain. If I can build it with x.py, then I'll go and figure that out.

I guess what I'd really like to be able to do is to register my toolchain with rustup in such a manner than it "just works", and so that my users can use rustup to install nightlies or my toolchain and not have to worry about whether to use rustup or some other mechanism.

Perhaps it means being able to specify something along the lines of allowing RUSTUP_DIST_SERVER being a colon separated list of servers to consult?

Unfortunately right now there isn't a way to have multiple dist servers or channels other than stable nightly and beta, but that is an interesting idea which we could potentially flesh out. There isn't good documentation for generating channel manifests right now, and the only code for that is in the rust tree, though I suppose if you're generating a custom toolchain from scratch then you can just build a full channel for yourself in your own CI I suppose. I'll have a think on my flight about what it might take to support arbitrary custom channels and/or multiple dist servers, but right now I'll not be able to promise anything concrete any time soon.

I'm still not certain how this would operate. First would be to flesh out a prospective use-case including example commands you'd expect your users to execute. Then we can think from there. if you have ideas then please let me know.

I guess my ideal scenario would be that we would host a set of files on a local server someplace. The user would set an environment variable (or perhaps use a file configuration similar to rust-toolchain) that causes that server location to be looked at in addition to the regular locations. Then they would use rustup as per " normal" specifying either an official or custom toolchain name.

What we're currently doing is to build the toolchain and all of the components and install them via rustup toolchain link.

So you'd like to be able to add a dist server and channels for that dist server (e.g. so you can do rustup toolchain install davestable ?

I think so - without actually knowing what's involved with setting up a dist server/channels. I'm assuming that it's just some files living on a web server.

I work with dave and we use the toolchain he's built for development so that we can target iOS. We have a setup script that he wrote that makes it straightforward for everyone on our team to get the toolchain installed locally but having it set as the default toolchain seems to break a lot of tooling. I've seen issues with just about every tool I've used that wants to interact with rustup (usually to ensure that some component is installed) because they hit this same error.

In my ideal world we'd be able to do something like rustup channel add our-custom-channel https://example.com/path/to/manifest and then our CI could publish builds there and rustup update our-custom-channel would work like it does on the standard channels.

rustup is wonderful and lots of tooling leverages it to provide a turn-key developer experience. It'd be awesome to find a way to make that work better with custom toolchains involved.

I figured that approach might be what you were hoping for. I really do want to supprt arbitrary custom dist channels in the future, but right now there's a lot of hard-coding for the three channels we have on rust-lang -- Thank you for that comment, it is useful and I hope we can continue to discuss things when I have the time and energy at the same point to begin work on this.

Was this page helpful?
0 / 5 - 0 ratings