rust-lang/cargo

Specify version of Rust required

BenMorganIO opened this issue · 6 comments

Coming from a ruby background, inside of a Gemfile you would be able to specify a version of ruby that your project was using. This was quite helpful.

Example:

source "https://rubygems.org"
ruby "2.2.0"

Since Rust is constantly changing as it nears 1.0 and goes beyond, I'm wondering if Cargo is able to do this? This would be helpful in managing dependencies.

The issue of rust versioning for dependencies occurred when I tried to use start up the nickel demo application. It did not work on rust 1.0.0.alpha.

  • Is there a way for libraries to specify the required version(s) of rust?
  • Is there a place in Cargo.toml to specify your applications version of rust?

Maybe:

[package]

rust = "1.0.0.alpha"

This specifically is a dupe of #837 and #1044 and is somewhat related to #967.

In general I do not think that we have enough experience with a post-1.0 Rust compiler to render a verdict on whether a feature like this will be necessary right out of the gate. I suspect that what I might imagine the feature would look like today may be quite a different picture a year or so from now.

I'm going to close this for now (as with the dupe issues) for the same reasons, those being that right now I do not believe we want to take action here and we always can do so after the fact :)

@alexcrichton I think we might be able to get a half win. Is it valid syntax to add to one's Cargo.toml:

[package]

rust = "1.0.0.alpha"

If it isn't, then I think the best thing is to just allow that and either do nothing with it or include it in the Cargo.lock file. My reasoning is that a version manager for rust is going to pop up sooner or later (if it hasn't already such as rsvm). A version manager should be able to look for a Cargo.lock or Cargo.toml file and if it sees "hey, I'm version x.x.x of rust", then that version manager can auto set it for the developer. Something like what rvm does.

That's the least amount of work and functionality that I can think of from Cargo, everything else belongs to a developer's version manager.

Currently you can put any valid syntax in a manifest, but you'll get warnings about unused keys. The lockfile also contains a metadata section which is blindly preserved by Cargo to be forwards-compatible with a feature such as this.

Here's an example demonstrating the need for this feature: briansmith/ring#521. When code fails to build, there are all kinds of possible reasons. If we know the code won't build with an older version of rustc, then having some way of informing the user of that can save both the user and the crate maintainer a lot of time.

Being unable to specify the rustc version my crate depends on, it is hard to adopt the ergonomic improvements coming with Rust 1.17.