1
votes

I want to create a library for rust. This is the Cargo.toml file for my project :

[package]
name = "binary_tree"
version = "0.0.1"
authors = ["Guillaume Bersac <[email protected]>"]

[lib]
test = true
plugin = false

This is the file of my repository :

Cargo.toml
README.md
src
|_node.rs

When I run the command "cargo run" or "cargo build" or "cargo test", I get the following error message :

Cargo.toml is not a valid manifest

expected a value of type array, but found a value of type table for the key lib

How to format my Cargo.toml so that it compile correctly ?

2
What Cargo and Rust versions are you using? It sounds to me like you’re using an old version of Cargo.Chris Morgan

2 Answers

5
votes

Are you running the latest rustc and cargo? If not, I think you used to need [[lib]], which creates a table array in TOML.

1
votes

This is the correct Cargo.toml :

[package]
name = "binary_tree"
version = "0.0.1"
authors = ["Guillaume Bersac <[email protected]>"]

[[lib]]
name="binary_tree"
test = true
plugin = false

It looks like I am running an old version of cargo. It is strange because I installed it yesterday following the official guide and using this command :

$ curl -s https://static.rust-lang.org/rustup.sh | sudo sh

My rustc version is : rustc 0.13.0-nightly (40b244973 2014-10-14 23:22:20 +0000)

My cargo version is : cargo 0.0.1-pre-nightly (9788700 2014-10-15 20:14:53 +0000)