rust-cargo

How to have different dependencies depending on OS family

柔情痞子 提交于 2019-12-04 00:16:19
I'm writing a cross-platform library that has platform specific dependencies, one for unix-like platforms, and one for windows. These crates only compile on specific platforms, wherefore I can't just add them all under dependencies normally. In the actual rust code I use cfg attributes, like #[cfg(unix)] to compile certain code for certain platforms, and I want to do something similar in the Cargo.toml, or in a build script, for the dependencies. Currently, I'm using target triplets like these: [target.i686-unknown-linux-gnu.dependencies.crate1] git = repo1 [target.x86-unknown-linux-gnu

Is it possible to have Cargo fetch dependencies from a private remote git?

半世苍凉 提交于 2019-12-04 00:10:52
I have an account on an ssh-friendly lab machine where I store a lot of private projects so I can access them from multiple computers (and it allows me to only use my few private Github repos for things multiple people will work on). It seems like Rust is well-equipped to fetch local and public data by using things like [dependencies.foo] git = "https://github.com/bar/foo" [dependencies.baz] path = "/path/to/baz" But I haven't found a way to get it to work using ssh git (e.g. git = "git@github.com:bar/foo" , or in my case labmachine:bar/foo ). I have passwordless/keygen ssh set up, if that

“unresolved import — maybe a missing extern” When extern declaration exists

Deadly 提交于 2019-12-03 23:48:57
问题 I have a small project which built with no issues when it was all in one big .rs file. I wanted to make it easier to work with, so I broke it up into modules, and the project is now structured like this: ├── GameState │ ├── ballstate.rs │ ├── collidable.rs │ ├── gamestate.rs │ ├── mod.rs │ └── playerstate.rs ├── lib.rs └── main.rs In ballstate.rs , I need to use the rand crate. Here's an abbreviated version of the file: extern crate rand; pub struct BallState { dir: Point, frame: BoundingBox

cargo ssl download error behind proxy on windows

房东的猫 提交于 2019-12-03 17:16:50
I cannot get cargo to commence any downloads under windows behind an authenticated proxy. Here are my proxy settings:- C:\Users\ukb99427\Downloads λ set | grep http https_proxy=http://user:pass@corporate.proxy:8080 http_proxy=http://user:pass@corporate.proxy:8080 Note the http s _proxy has a http address. This allows something like git and incidentally rustup-init and rustup to work fine. Output from those are λ rustup update info: syncing channel updates for 'stable-x86_64-pc-windows-msvc' info: syncing channel updates for 'nightly-x86_64-pc-windows-msvc' info: latest update on 2017-11-10,

How to get a release build with debugging information when using cargo?

谁说我不能喝 提交于 2019-12-03 06:32:30
问题 The following command $ cargo build produces a non-optimized build with debugging information. On the contrary, $ cargo build --release produces an optimized build without debugging information. Is there a way of producing an optimized build with debugging information? I need this to get meaningful profiling information. 回答1: As shown in the Cargo documentation, modify the release profile to include debugging symbols: [profile.release] debug = true See also Can tests be built in release mode

error[E0554]: #![feature] may not be used on the stable release channel Couldn't install racer using cargo

我是研究僧i 提交于 2019-12-03 04:40:31
I'm trying to install racer using cargo, so I executed the command cargo install racer in the terminal and it resulted in the error: error[E0554]: #![feature] may not be used on the stable release channel --> /home/rajkumar/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:47:34 | 47 | #![cfg_attr(feature = "nightly", feature(macro_vis_matcher))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0554]: #![feature] may not be used on the stable release channel --> /home/rajkumar/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:48:34 | 48 | #![cfg_attr

How to launch a Rust application from Visual Studio Code?

南楼画角 提交于 2019-12-02 22:35:18
I have installed the Visual Studio Code extensions for Rust: I want to run my project and I don't understand where to click. I tried clicking Run Task , Run build task , Configure Default build task , but nothing reasonable happens. Using the integrated terminal Shortcut to run the integrated terminal: Ctrl + ` (Ctrl + backtick) Run the following command in the integrated terminal: cargo run Notes: Open the Code editor from your project folder ( code . command inside project folder terminal, or in GUI mode: right-click inside project folder and select Open With Code ) then press Ctrl + ` (

How to get a release build with debugging information when using cargo?

萝らか妹 提交于 2019-12-02 20:10:45
The following command $ cargo build produces a non-optimized build with debugging information. On the contrary, $ cargo build --release produces an optimized build without debugging information. Is there a way of producing an optimized build with debugging information? I need this to get meaningful profiling information. As shown in the Cargo documentation , modify the release profile to include debugging symbols: [profile.release] debug = true See also Can tests be built in release mode using Cargo? How to compile and run an optimized Rust program with overflow checking enabled Does Cargo

How to install Cargo on a RHEL Linux server?

我们两清 提交于 2019-12-02 13:33:52
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? 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 --enable rhel-variant-rhscl-7-rpms Add the Red Hat Developer Tools key to your system: cd /etc/pki/rpm-gpg wget

How to make cargo to save-analysis?

扶醉桌前 提交于 2019-12-02 08:56:31
问题 How can I make cargo to save-analysis ? I know that I can do this with rustc by calling rustc -Zsave-snalysis <files...> But, I couldn't figure out for cargo . And also I like to know how I can read them back to rls_analysis data structures. I tried cargo rustc -Zsave-analysis, but it doesn't seem to work. I also tried export RUSTC_SAVE_ANALYSIS=api, no work too. What I want to do is getting fully qualified path (e.g. ::foo1::foo2::Foo3 ) to the types notated in source code. If there's other