emk / heroku-buildpack-rust

A buildpack for Rust applications on Heroku, with full support for Rustup, cargo and build caching.
522 stars 186 forks source link

Specify desired Rust version using `Cargo.toml` `[metadata]` section with `rustup_channel`? #11

Closed emk closed 6 years ago

emk commented 8 years ago

Right now, we use a RustConfig file to specify the VERSION we want to use. This adds one more unnecessary bit of clutter to a project repo.

There's a discussion of this at https://github.com/rust-lang/cargo/issues/1214 (closest) and https://github.com/rust-lang/cargo/issues/837 (upstream tracking issue).

But Cargo has a [metadata] section we could use, as shown here. It would be great to add a rustup_channel to this file:

[metadata]
rustup_channel="stable"

We could use cargo read-manifest to convert this to JSON on standard output. However, I'm not sure whether Heroku's build envrionment has any good JSON-parsing tools, so this might not actually get us any closer. Would it be reasonable/possible to install a tool like jq at build time on Heroku to parse the JSON for us, or is this overkill?

In theory, Rustup might someday decide to support a standard way of specifying which version of Rust to use with a given project. The tracking bug for this is at https://github.com/rust-lang-nursery/rustup.rs/issues/460.

emk commented 8 years ago

In #13, we're discussing the possibility of using heroku config:set RUST_CHANNEL=nightly instead of putting it in Cargo.toml, because we need to support the case with no Cargo.toml.

emk commented 8 years ago

At this point, we're committed to having some mechanism for specifying configuration via environment variables, thanks to RUST_SKIP_BUILD in #14. So this issue can probably be put on the back burner until the Cargo and Rustup maintainers come up with a standard way to specify the Rust version.

anp commented 6 years ago

Rustup now supports a rust-toolchain file in the project root (see https://github.com/dikaiosune/rust-dashboard/blob/master/rust-toolchain for an example) -- what about reading that for the rustup update/install?

EDIT: it's specified here

emk commented 6 years ago

This is a great idea, and I would eagerly merge a PR to implement this! However, I don't have time to tackle it myself this week, or probably next.