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
10
votes
3 answers

Rust compiler can't find crate for 'std'

I recently downloaded and unpacked the Rust Language from this site (Linux 64-bit). I then installed Rust using the given script in the download install.sh: root@kali:~# /root/rust-1.9.0-x86_64-unknown-linux-gnu/install.sh install: uninstalling…
ljeabmreosn
  • 970
  • 1
  • 9
  • 26
10
votes
1 answer

How to switch dependencies based on build profile

I want to use a feature from a dependency when I build in release profile and I don't want to use any feature while testing/development. For example, the dependency is normally defined as: [depenencies.my_dep] version = "*" But when I build in…
Krishna
  • 186
  • 1
  • 8
10
votes
1 answer

How to add already built rust library into cargo build?

I have a project, let's call this project Master. This Master projects depends on other library I've already written and that is separated in different project, let's call this project Library. Adding git dependencies or unbuilt project dependencies…
user1930502
9
votes
2 answers

error: linker `x86_64-w64-mingw32-gcc` not found

I am using MacOS Big Sur, and i am trying to cross compile to windows, but the problem is, this "error: linker x86_64-w64-mingw32-gcc not found" prevents me from doing that, here are my cargo dependencies: [dependencies] rand = "0.8.4" macroquad =…
Macho Onion
  • 207
  • 2
  • 8
9
votes
2 answers

How to solve error: no such subcommand: `generate`

I have installed rust using curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh on Ubuntu. But when I tried cargo generate --git https://github.com/CosmWasm/cw-template.git --name FOO I met the error like this error: no such subcommand:…
Bikas Lin
  • 689
  • 5
  • 16
9
votes
1 answer

error[E0463]: can't find crate for `core` while building rust project for wasm32-unknown-unknown

I get the following error message: error[E0463]: can't find crate for `core` | = note: the `wasm32-unknown-unknown` target may not be installed error: aborting due to previous error For more information about this error, try `rustc --explain…
Aman Verma
  • 113
  • 1
  • 7
9
votes
1 answer

Fail to run cargo after install rust on raspberry pi 4

I was trying to install rust on Raspberrypi 4 using the recommended install script: pi@raspberrypi:/tmp $ curl https://sh.rustup.rs -sSf | sh But after reboot, cargo cannot be found: pi@raspberrypi:~ $ cargo error: command failed: 'cargo' error:…
user13796674
  • 121
  • 1
  • 4
9
votes
0 answers

failed to run custom build command for `ring v0.16.12`

I am building this (https://github.com/solana-labs/solana) on my new Mac m1 and it failed. The author of ring says it can be fixed by upgrading dependency (https://github.com/briansmith/ring/issues/1163). I tried add ring = "0.16.19" to cargo.toml…
Jill Clover
  • 2,168
  • 7
  • 31
  • 51
9
votes
1 answer

Define features for Cargo profiles in Cargo.toml

I'm using Cargo Features (https://doc.rust-lang.org/cargo/reference/features.html) to specify conditional compilation options. Is there a way to enable a set of these features for a given Cargo profile…
ynimous
  • 4,642
  • 6
  • 27
  • 43
9
votes
1 answer

RUST cargo run task with arguments in vscode

Is there a way to specify arguments to a RUST cargo command running as VS CODE task? Or should I be trying this as an NPM script? (of course, this is RUST, so I am using CARGO and npm, creating a package.json would be odd). The Build task works…
Dr.YSG
  • 7,171
  • 22
  • 81
  • 139
9
votes
2 answers

How can I change the number of threads Rayon uses?

I'm using the Rayon library: extern crate rayon; const N: usize = 1_000_000_000; const W: f64 = 1f64/(N as f64); fn f(x: f64) -> f64 { 4.0/(1.0+x*x) } fn main() { use rayon::prelude::*; let sum : f64 = (0..N) …
asyraaf azhar
  • 383
  • 4
  • 12
9
votes
1 answer

Unresolved import when importing from a local crate with a main.rs file

I have included a library as a submodule in my program. The structure looks like this: . ├── my_lib/ ├── Cargo.toml └── src/ ├── lib/ ├── mod.rs └── foo.rs └── main.rs ├── src/ └──…
Dani M
  • 1,173
  • 1
  • 15
  • 43
9
votes
1 answer

Enable a Cargo feature by default when the target arch is WASM?

Part of my Cargo.toml for my crate: [features] wasm = ["ed25519-dalek/nightly", "rand/wasm-bindgen", "js-sys"] This works, when the crate is used in another project, and the "wasm" feature is explicitly chosen. I want to automatically enable this…
user964375
  • 2,201
  • 3
  • 26
  • 27
9
votes
2 answers

Overriding Rust installation default paths `$HOME/.cargo` and `$HOME/.rustup`

In Rust, by default, files are placed in $HOME/.cargo and $HOME/.rustup. Is there any way to override these defaults? I am trying to debug an obscure issue and I want to try changing the file locations.
Martin Ellison
  • 1,043
  • 1
  • 13
  • 25
9
votes
1 answer

Why does Rust compile my project again with `cargo build --release` followed by `cargo run`?

Rust documentation teaches us that cargo build creates a binary file after compiling, which we can execute with cargo run. cargo run will again compile the code if it notices any change after cargo build command is executed. It also says that cargo…
Muhammad Naufil
  • 2,420
  • 2
  • 17
  • 48