rust-cargo

Cannot write keyfile with crate

☆樱花仙子☆ 提交于 2019-12-13 03:34:12
问题 I am trying to use the function here https://docs.rs/ethkey/0.2.5/ethkey/ to write a keyfile for ethereum : let key = EthAccount::load_or_generate("Users/Documents/Code/Thor/thor/parity/keys", "passwd") .expect("should load or generate new eth key"); println!("{:?}", key.address()); unfortunately, it doesnt work and it get the following error: thread 'main' panicked at 'should load or generate new eth key: Error(SerdeJsonError(Error("Is a directory (os error 21)", line: 0, column: 0)), State

Is it possible to specify `panic = “abort”` for a specific target?

若如初见. 提交于 2019-12-12 13:34:34
问题 If I specify panic like this, it works for all targets: [profile.release] panic = "abort" I want to specify panic = "abort" only for target=arm-linux-androideabi . 回答1: You will need to add a .cargo/config to your project and use it to specify the panic settings instead of Cargo.toml: [target.arm-linux-androideabi] rustflags = ["-C", "panic=abort"] The two main configuration headings you will want to look at are [target.$triple] and [target.'cfg(...)'] . 来源: https://stackoverflow.com

Turn off default-features in dependency of dependency

故事扮演 提交于 2019-12-12 13:03:47
问题 I have a chain of dependencies that end in depending optionally on a deprecated library. Concretely, I want to use nalgebra which depends indirectly on rustc-serialize as follows: nalgebra -> alga -> num-complex -> (optional default) rustc-serialize I can list the num-complex dependency in my Cargo.toml file and turn off the optional rustc-serialize dependency ( num-complex = { version = "0.1.42", default-features = false } ), but is there a way to turn off this option all the way up the

How can I optionally pass rustc flags depending on a Cargo feature?

流过昼夜 提交于 2019-12-12 10:04:22
问题 The program I'm writing runs much faster when the -C target-cpu=native flag is passed to rustc . I want to give users a simple, platform-independent way to enable this when compiling, so I added a Cargo feature cpu_native = [] in Cargo.toml and created this Cargo config in my project: [target.'cfg(cpu_native)'] rustflags = ["-C", "target-cpu=native"] However, this has no effect on my program, and passing --features cpu_native to Cargo does not even trigger a recompile. Changing to the

How to set logging level while running cargo test? [duplicate]

一曲冷凌霜 提交于 2019-12-12 09:38:18
问题 This question already has answers here : How to initialize the logger for integration tests? (5 answers) Closed 3 years ago . I need to change the logging level while running the unit tests for a library. I am using the cargo test command to run the tests. Is there any way to specify the logging level on the command line? From the documentation of the log crate, it seems like I need to define an environment variable separately. That may not be convenient as I would like to change the logging

How can a binary installed with cargo install be removed?

杀马特。学长 韩版系。学妹 提交于 2019-12-12 04:35:45
问题 How can a crate like rustfmt be removed after being installed with cargo install 回答1: Global binary crates like rustfmt can be removed with the command cargo uninstall [options] <spec> . Use cargo help uninstall to get more detail. 来源: https://stackoverflow.com/questions/44664638/how-can-a-binary-installed-with-cargo-install-be-removed

error: native library `openssl` is being linked to by more than one version of the same package

夙愿已清 提交于 2019-12-12 04:17:42
问题 I'm facing this problem when I try to cargo build: error: native library openssl is being linked to by more than one version of the same package, but it can only be linked once; try updating or pinning your dependencies to ensure that this package only shows up once openssl-sys v0.6.7 openssl-sys v0.7.13 Cargo and Rust versions: $ cargo --version cargo 0.11.0-nightly (3ff108a 2016-05-24) $ rustc --version rustc 1.11.0-nightly (7746a334d 2016-05-28) Files: Cargo.toml Cargo.lock can't get why

error: failed to run custom build command for `onig_sys v61.1.0`

血红的双手。 提交于 2019-12-12 01:13:37
问题 error: failed to run custom build command for onig_sys v61.1.0 I am compiling the rust program https://github.com/trishume/syntect by running make packs . However it throws the error: $ make packs cargo run --example gendata -- synpack testdata/Packages assets/default_newlines.packdump assets/default_nonewlines.packdump Compiling onig_sys v61.1.0 error: failed to run custom build command for `onig_sys v61.1.0` process didn't exit successfully: `D:\syntect\target\debug\build\onig_sys

Refactoring to workspace structure causes extern crate imports to not work

只谈情不闲聊 提交于 2019-12-11 15:52:33
问题 I need different parts of my project to use different versions of the same extern crate so I'm refactoring my Rust project to be divided into multiple packages via the workspaces system using this as a guide. Doing so is causing all my pub extern crate imports to not work. This post is very similar to one I created very recently and then deleted - this version contains a minimal, complete, and verifiable example. Here's my project structure workspace_test/ root/ src/ main.rs Cargo.toml Cargo

Where does Cargo put the git requirements?

孤者浪人 提交于 2019-12-11 11:44:18
问题 When compiling a project, cargo automatically downloads the requirements, specified in the Cargo.toml, given as a git-repository. E.g. [dependencies.piston] git = "https://github.com/PistonDevelopers/piston" will result in Updating git repository 'https://github.com/PistonDevelopers/opengl_graphics' when compiling. Where does it save those repositories on my disk? I'm using Windows, does this change anything? 回答1: man cargo gives: FILES ~/.cargo Directory in which Cargo stores repository data