rust-cargo

Where can I find .cargo/config?

懵懂的女人 提交于 2019-12-02 02:37:26
问题 I don't have this file in c:/user/me/.cargo/ 回答1: As described in the Cargo documentation, there's no one place for .cargo : Cargo allows local configuration for a particular project as well as global configuration, like git. Cargo extends this to a hierarchical strategy. If, for example, Cargo were invoked in /projects/foo/bar/baz , then the following configuration files would be probed for and unified in this order: /projects/foo/bar/baz/.cargo/config /projects/foo/bar/.cargo/config

How do I exclude a file from being built on OS X?

故事扮演 提交于 2019-12-01 21:33:39
问题 I have src/bin/linux-only.rs which does some things which work on Linux only (e.g. libc bindings which only exist on Linux). I want to exclude that file from being built on OS X. I started putting #[cfg(target_os = "linux")] on every block in linux-only.rs but that is cluttering up the source code beyond any reason. Is there a nicer way to do this? 回答1: Writing #![cfg(target_os = "linux")] (note the exclamation mark) at the top of the file will work for the whole file (as long as it contains

Is it possible to deactivate file locking in cargo?

拥有回忆 提交于 2019-12-01 19:26:31
I want to run the following commands side by side cargo watch "check" cargo watch "build" I want to run cargo watch build in the background and use cargo watch check to look at the error messages. The problem is that cargo watch check always runs after cargo watch build and then also needs to wait on the file lock cargo check Blocking waiting for file lock on build directory I don't think that a file lock would be required for cargo check. Is it possible to disable file locking in cargo? malbarbo I don't think that a file lock would be required for cargo check. I can think of in one reason:

How do I exclude a file from being built on OS X?

我的未来我决定 提交于 2019-12-01 19:25:51
I have src/bin/linux-only.rs which does some things which work on Linux only (e.g. libc bindings which only exist on Linux). I want to exclude that file from being built on OS X. I started putting #[cfg(target_os = "linux")] on every block in linux-only.rs but that is cluttering up the source code beyond any reason. Is there a nicer way to do this? Writing #![cfg(target_os = "linux")] (note the exclamation mark) at the top of the file will work for the whole file (as long as it contains a single module), not just for the next block (item). Source: Rust reference . Edit : if you can move that

Why can a Cargo package only have one library target?

大城市里の小女人 提交于 2019-12-01 18:14:18
According to its manual , Cargo packages can have multiple executable targets, but only one library target is allowed. A package can contain zero or one library crates and as many binary crates as you’d like. There must be at least one crate (either a library or a binary) in a package. Why is it limited to one? What are the reasons and benefits? Cargo is primarily a package manager. Thus, the primary role of a package is to define a library. When we use a crate as a dependency, we only specify the package name in our Cargo.toml . Since there can be at most one library, Cargo doesn't need you

Cargo on Windows behind a corporate proxy

烂漫一生 提交于 2019-12-01 17:22:14
I think this is a very common issue among those who want to use Cargo with Windows at work; I have seen multiple GitHub issues and forum posts related to it, but none of the answers solved my problems. Whenever I try to build some code pointing to a crates.io crate, I get the following error: Downloading <package> error: unable to get packages from source Caused by: failed to download package <package> from <package address> Caused by: SSL connect error What can I do to fix this? I know that Cargo can use the settings at .cargo/config and that the proxy details can be included there, but it

How to access current cargo profile (build, test, bench, doc, …) from the build script (build.rs)

流过昼夜 提交于 2019-12-01 17:08:34
问题 I want to write a custom build.rs script that generates some diagrams to accompany the documentation for a crate I'm working on. I want this script to run only when I run cargo doc , not the other profiles ( cargo build , cargo test , ...). What would be the best way to do that? I was hoping that cargo would pass this info to build.rs in the PROFILE env variable, but that seems to only contain "debug" or "release". 回答1: This is not possible as of Rust 1.38. Cargo issue #4001 tracks the

Cargo on Windows behind a corporate proxy

折月煮酒 提交于 2019-12-01 16:26:46
问题 I think this is a very common issue among those who want to use Cargo with Windows at work; I have seen multiple GitHub issues and forum posts related to it, but none of the answers solved my problems. Whenever I try to build some code pointing to a crates.io crate, I get the following error: Downloading <package> error: unable to get packages from source Caused by: failed to download package <package> from <package address> Caused by: SSL connect error What can I do to fix this? I know that

Could not exec the linker `cc` error when running “cargo build”

孤人 提交于 2019-12-01 16:03:26
I just installed Rust on my Mac and rustc --version --verbose displays rustc 1.0.0-nightly (91bdf23f5 2015-03-09) (built 2015-03-08) binary: rustc commit-hash: 91bdf23f504f79ed59617cde3dfebd3d5e39a476 commit-date: 2015-03-09 build-date: 2015-03-08 host: x86_64-apple-darwin release: 1.0.0-nightly I cloned a couple of repositories ( postgres-extension and erlang-rust-nif ) and ran cargo build upon both of them. Both reported the error error: could not exec the linker `cc`: No such file or directory (os error 2) error: aborting due to previous error Additionally, I wasn't able to compile a simple

How difficult is it to allow parallel compilation of code with the Rust stable and nightly channels?

╄→гoц情女王★ 提交于 2019-12-01 15:49:56
The default file-tree created by Cargo allows parallel compilation of release and debug builds as they are located in their own directories; target/release and target/debug , respectively. How difficult is it to also allow parallel compilation of stable / nightly -compiler. For example using the directories target/debug/stable target/debug/nightly I am aware it can be done with jails/containers, but I was hoping for a somewhat more Cargo-ish solution. Modern Rust I believe that your main problem of rebuilding dependencies no longer exists: $ cargo +nightly build Updating crates.io index