rust-cargo

How to tell Cargo to use a git repository as source for an indirect dependency instead of crates.io?

喜你入骨 提交于 2020-01-02 01:02:09
问题 A few days ago, cross-compiling to JavaScript via Emscripten has finally hit nightly. I wanted to compile a project using glium in that manner. However, there are still many Emscripten-related bugs in many crates. While maintainers usually fix those bugs quickly, they don't necessarily release those bug fixes to crates.io immediately. In my case, glium depends on glutin . glutin had a bug which is fixed now, but only in the git repository, not on crates.io . Note : glutin is not a direct

Optimising cargo build times in Docker

爷,独闯天下 提交于 2020-01-01 11:57:13
问题 I am developing an API with Rust, and am managing the environments, including the external database with Docker. Every time I make a change to the API code, cargo rebuilds, and since Docker doesn't cache anything to do with the ADD statement to copy the Rust directory over to the container, it re-downloads all the packages, which is a fairly lengthy process since I'm using Nickel, which seems to have a boatload of dependencies. Is there a way to bring those dependencies in prior to running

How to install Cargo on a RHEL Linux server?

可紊 提交于 2019-12-31 07:41:50
问题 I tried installing Cargo on a RHEL server with: curl https://sh.rustup.rs -sSf | sh but after finishing, I get the response: cargo -bash: cargo: command not found Is there a different way to install? 回答1: First enable the rhel-7-variant-devtools-rpms repository subscription-manager repos --enable rhel-7-varient-devtools-rpms Replace variant with the Red Hat Enterprise Linux system variant ( server or workstation ) Enable the rhel-variant-rhscl-7-rpms repository: subscription-manager repos -

How to install Cargo on a RHEL Linux server?

喜夏-厌秋 提交于 2019-12-31 07:41:33
问题 I tried installing Cargo on a RHEL server with: curl https://sh.rustup.rs -sSf | sh but after finishing, I get the response: cargo -bash: cargo: command not found Is there a different way to install? 回答1: First enable the rhel-7-variant-devtools-rpms repository subscription-manager repos --enable rhel-7-varient-devtools-rpms Replace variant with the Red Hat Enterprise Linux system variant ( server or workstation ) Enable the rhel-variant-rhscl-7-rpms repository: subscription-manager repos -

How do I import multiple versions of the same crate?

a 夏天 提交于 2019-12-31 04:23:04
问题 As discussed in Is it documented that Cargo can download and bundle multiple versions of the same crate?, it's possible for Cargo to pull in multiple versions of the same crate for a single program. How do I access both of these versions concurrently? 回答1: As of Rust 1.31, you can use the rename-dependency Cargo feature: [dependencies] futures-01 = { package = "futures", version = "0.1.0" } futures-03 = { package = "futures", version = "0.3.0" } You can choose whatever name you want for the

Error installing a crate via cargo: specified package has no binaries

删除回忆录丶 提交于 2019-12-28 04:00:16
问题 I'm trying to install a Rust crate on my system (Arch Linux) using Cargo. I can search for crates and find what I need, for example: $ cargo search curl | head -n3 Updating registry `https://github.com/rust-lang/crates.io-index` curl (0.3.0) Rust bindings to libcurl for making HTTP requests curl-sys (0.2.0) Native bindings to the libcurl library When I try to install it, I get the following error: $ cargo install curl Updating registry `https://github.com/rust-lang/crates.io-index` error:

Rust and loader paths (@rpath, @loader_path) on OS X

末鹿安然 提交于 2019-12-24 01:55:26
问题 I'm trying to solve a problem with foreign library loading with Rust. Inputs: I have an executable rtest and a dylib libcpp2rs.dylib . The library is linked to the executable through FFI: #[link(name="cpp2rs")] extern { ... } My build.rs file (I'm passing an extra argument with libcpp2rs.dylib location): pub fn main() { println!("cargo:rustc-link-search=native=./cpplib/bin"); } And my Cargo.toml file: [package] name = "rtest" version = "0.1.0" authors = ["astavonin"] build = "build.rs" rpath

Cannot compile the ring crate: file not found for module `montgomery`

99封情书 提交于 2019-12-24 00:43:23
问题 Cargo is not compiling with the following error: $ cargo build Compiling ring v0.12.1 error[E0583]: file not found for module `montgomery` --> C:\Users\jmccrae\.cargo\registry\src\github.com1ecc6299db9ec823\ring-0.12.1\src\arithmetic/arithmetic.rs:15:9 | 15 | pub mod montgomery; | ^^^^^^^^^^ | = help: name the file either arithmetic\montgomery.rs or arithmetic\montgomery\mod.rs inside the directory "C:\\Users\\jmccrae\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\ring-0.12.1\\src\

What files in a Cargo project should be in my .gitignore?

我怕爱的太早我们不能终老 提交于 2019-12-23 19:11:27
问题 I created a "hello world" Rust app using cargo new . When I executed git status it showed a bunch of files: A rust/welcomec/Cargo.lock A rust/welcomec/Cargo.toml A rust/welcomec/src/main.rs A rust/welcomec/target/debug/.cargo-lock A rust/welcomec/target/debug/.fingerprint/welcomec-2d68725c8fae6fd1/bin-welcome-2d68725c8fae6fd1 A rust/welcomec/target/debug/.fingerprint/welcomec-2d68725c8fae6fd1/bin-welcome-2d68725c8fae6fd1.json A rust/welcomec/target/debug/.fingerprint/welcomec-2d68725c8fae6fd1

Why should I use Cargo if “cargo build” is slower than running rustc directly?

不问归期 提交于 2019-12-23 05:22:36
问题 I created a simple hello world program: fn main() { println!("Hello, world"); } When compiling the code using rustc vs cargo build , the cargo command appears slower. It takes 1.6s for cargo build vs 1s for rustc . See the timestamps on the right in the screenshot. Why is this? Why should I still use cargo? 回答1: As Pavel Strakhov said Cargo is not a compiler, it's a package manager. It runs rustc and does some extra work (e.g. resolves dependencies), so it can't be faster than bare rustc .