Questions tagged [rust-cargo]

Cargo is the official package manager for the Rust programming language.

Cargo is the official package manager for the Rust programming language. Using a manifest, the programmer can provide metadata about a project, including dependencies, which Cargo can automatically download and compile before compiling the project itself.

You can find more information in the cargo book and browse the crates (Rust packages) in crates.io.

2044 questions
20
votes
1 answer

How can I downgrade or install an older version of a tool I installed with `cargo install`?

I would like to install Xargo v0.3.10 on my machine. The current version of Xargo is v0.3.11 and it is installed by the cargo install xargo command. How can I install an older version of Xargo?
Dragonight
  • 1,033
  • 2
  • 10
  • 20
20
votes
2 answers

How to specify the exact version of a dependency?

I'm using $ cargo --version cargo 0.21.0-beta (7e00b82d9 2017-07-17) I created a simple project with cargo new --bin test1, and then I added a dependency: [dependencies] lazy_static = "0.2.2" to Cargo.toml (according to this such version exists)…
user1244932
  • 7,352
  • 5
  • 46
  • 103
20
votes
2 answers

Is there any way to rename a Cargo project?

I created a project using: cargo new projectname --bin. How do I change projectname to some other name? I checked the man page and the Cargo documentation. I also ran: cargo help cargo --list man cargo In the metadata files (Cargo.toml,…
David Sainez
  • 6,446
  • 1
  • 22
  • 45
20
votes
2 answers

How to cross compile from Mac to Linux?

I wrote a little game using Rust, and I used cargo build --release to compile a release version on Mac. I tried to share this with my friend who is using Ubuntu, but when he tried to run the binary, he got the following error: cannot execute binary…
FrontMage
  • 641
  • 1
  • 5
  • 13
20
votes
1 answer

Where does Cargo get my name and email from when creating a project?

Working through Rust's Getting Started page on macOS, I ran the following command for Cargo to generate a project: cargo new hello_world --bin When I inspected the Cargo.toml file, it contained my real name as well as my email address. From where…
ross
  • 526
  • 5
  • 19
20
votes
3 answers

How do I specify the linker path in Rust?

I'm trying to link a Rust program with libsoundio. I'm using Windows and there's a GCC binary download available. I can link it like this if I put it in the same folder as my project: #[link(name = ":libsoundio-1.1.0/i686/libsoundio.a")] #[link(name…
Timmmm
  • 88,195
  • 71
  • 364
  • 509
20
votes
4 answers

OpenSSL crate fails compilation on Mac OS X 10.11

I tried to install the Iron framework for Rust on Mac OS X 10.11.2, but it failed when I run cargo build or cargo run on compiling openssl's stuff: failed to run custom build command for `openssl-sys-extras v0.7.4` Process didn't exit successfully:…
rap-2-h
  • 30,204
  • 37
  • 167
  • 263
19
votes
1 answer

how to return current working directory from function?

has experience with high level programming languages. I read the Rust book and now trying to survive and understand how the "things" in Rust works. I would love that someone explain what the heck is - Ok(()) and how to deal with it? My goal is to…
pr0logas
  • 523
  • 1
  • 5
  • 14
19
votes
8 answers

How to fix diesel_cli link libpq.lib error with Postgres tools installed in Docker?

I'm trying (for hours now) to install the cargo crate diesel_cli for postgres. However, every time I run the recommended cargo command: cargo install diesel_cli --no-default-features --features postgres I wait a few minutes just to see the same…
CoderLee
  • 3,079
  • 3
  • 25
  • 57
19
votes
2 answers

How can I only show warnings if there are no errors?

Often during development, I have a bunch of unused imports and variables. I like to fix those after I have correctly working code. The warnings these generate cause me to scroll though the cargo build output to find errors among all the warnings. Is…
Mark
  • 18,730
  • 7
  • 107
  • 130
19
votes
1 answer

Where are modules installed by Cargo stored in a Rust project?

In NodeJS, all the packages installed by NPM are stored in the node_modules/ directory. Is there any such directory in Rust? Are the crates installed somewhere globally?
sidoshi
  • 2,040
  • 2
  • 15
  • 30
18
votes
1 answer

Blocking waiting for file lock on package cache when I added dependency to Cargo.toml file

I added a dependency to a rust project, then ran cargo run, this gave me this error: "Blocking waiting for file lock on package cache" I tried the solution I found online which was to delete the ~/.cargo/.package-cache file, however this has not…
sullyh7
  • 225
  • 1
  • 2
  • 6
18
votes
1 answer

Is there a way to enforce correct spelling of features?

Let's assume I have the following feature defined in Cargo.toml: [features] my_feature = [] And the following code lives in src/lib.rs: #[cfg(feature = "my_feature")] fn f() { /* ... */ } #[cfg(not(feature = "my_faeture"))] // <-- Mind the…
Peter Varo
  • 11,726
  • 7
  • 55
  • 77
18
votes
2 answers

Detect keydown?

I would like to detect a keydown event in Rust and then check if a combination of keys is pressed, in order to do further actions based on that. So basically support keyboard shortcuts in my Rust application. I've looked at some crates for example…
frankenapps
  • 5,800
  • 6
  • 28
  • 69
18
votes
1 answer

How can I specify the GLIBC version in cargo build for Rust?

I use rust 1.34 and 1.35. Currently it links to GLIBC_2.18. How can I limit cargo build to link GLIBC up to version 2.14?
Yixing Liu
  • 2,179
  • 1
  • 20
  • 36