Overriding dependencies in Cargo.toml


#1

Hey,

Pretty new to Rust, but I’m trying to build https://github.com/servo/rust-layers locally, but after running cargo build I get the following error:

   Compiling io-surface v0.2.0
/Users/tonydaly/.cargo/registry/src/github.com-88ac128001ac3a9a/io-surface-0.2.0/src/lib.rs:13:1: 13:30 error: #[feature] may not be used on the stable release channel
/Users/tonydaly/.cargo/registry/src/github.com-88ac128001ac3a9a/io-surface-0.2.0/src/lib.rs:13 #![feature(clone_from_slice)]

Looks like there is an issue with an old feature switch? So I fork io-surface and update it myself here: https://github.com/tonydaly/io-surface-rs/tree/feature-cleanup

I’ve then updated my local Cargo.toml file to add this as a dependency:

io-surface = { git = "https://github.com/tonydaly/io-surface-rs.git", branch = "feature-cleanup" }

However, now when I run cargo build it tries to build my branch and the old one? How can I override this? Or what’s the process to locally test updates to a dependency?

Any help appreciated


#2

Cargo has a special override mechanism for locally testing changes to dependencies.


#3

Thanks @mbrubeck that works great! However, I’m now getting the same error from a different package:

error: #[feature] may not be used on the stable release channel

Is this standard? Is the workaround just to use a Beta or Nighty release?


#4

Yes, you’d have to use nightly for that crate then. Some crates depend on unstable features like that (and some crates only do it if you opt into one of their features). Ideally the crate should be quite clear about this in its docs, albeit if it’s a syntax extension or something obviously unstable, they might not mention it.


#5

Servo predates stable Rust, and continues to rely on things like compiler plugins, so a lot of the crates we produce have only been used so far on nightly. But if you’d like a particular crate to be usable in stable Rust, please let us know. We’d be happy to take patches, or to help out ourselves if we have time.

It looks like one of the problem packages is rust-azure, which uses compiler plugins for serde and heapsize. These could probably be made optional or converted to work with syntex.


#6

Very few features are so good that they are worth using syntex for. Sorry for being such a party killer, but syntex can take 20 minutes or so to compile. racer is a project that’s so awesome that it can afford it, but few can.