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
0
votes
0 answers

Why do I keep on getting an error message even though libssl-dev is installed?

I have a rust project that uses the below crate. reqwest = { version = "0.11.18", features = ["blocking", "json"] } In order to make it work, I installed "libssl-dev" using the below command in the terminal. sudo apt install libssl-dev However,…
Saad
  • 33
  • 5
0
votes
1 answer

How to detect if some function is available in a library at configuration time?

Some libraries exposes functions and types inconsistently depending on the target platform. Notably libc and nix does that. How do I detect at configuration time if some function, like libc::mmap64 or libc::posix_fallocate is made available by the…
lvella
  • 12,754
  • 11
  • 54
  • 106
0
votes
0 answers

How can you check compile errors of file with dependencies that is no direct cargo target?

I want to check whether a module would compile within the context of a cargo project (i.e. all the dependencies as well as the rust edition from Cargo.toml loaded). As far as I understand, with cargo check, this would only work for specified…
Pinko
  • 39
  • 1
  • 8
0
votes
1 answer

How can I use cargo build scripts to create a binary

I would like to create a binary from a rust within a rust build script. I tried to create a file OUT_DIR/bin/hello_from_build_script_binary like this: use std::env; use std::fs; use std::path::Path; fn main() { let out_dir =…
cowlicks
  • 1,037
  • 1
  • 12
  • 20
0
votes
1 answer

Compiling sdl-based crates with Cargo causes linker errors (sdl2, pix-engine)

I'm running Ubuntu 20.04.6, with cargo 1.70.0 installed via the rustup installer script (rustup 1.26.0) running cargo run with the the pix-engine example program pasted into main.rs gave me this error error: linking with `cc` failed: exit status: 1 …
joeman
  • 1
  • 2
0
votes
0 answers

Error in Anchor Installation - cargo install --git https://github.com/coral-xyz/anchor avm --locked --force. I'am using cargo to install AVM

error[E0793]: reference to packed field is unaligned --> C:\Users\Kalyaan.cargo\registry\src\index.crates.io-6f17d22bba15001f\ntapi-0.3.7\src\ntexapi.rs:2783:52 | 2783 | *tick_count.QuadPart_mut() =…
0
votes
0 answers

How does cargo resolve conflicting dependency versions?

I have started to work on this open source repo. I don't understand how cargo resolves the deps because the Cargo.toml pins cairo-vm = "0.5.1" but their blockifier dependency pins 0.3.0. Consequently in the Cargo.lock the resolved version is 0.3.0…
ClementWalter
  • 4,814
  • 1
  • 32
  • 54
0
votes
2 answers

Do I need to explicitly return the value in `Ok` variant of `Result` while using `?` operator?

In rust we know that ? operator works like match expression. If the Result is Ok then the result in Ok variant is returned from this expression and if the Result is Err then the result in Err variant is returned from this expression and quits the…
Neon
  • 33
  • 2
0
votes
1 answer

Lifetimes for String slices

I'm going through the rust black book and it mentions lifetime elision rules, and how especially for functions inputting and returning &str (strings stored on the stack), don't need explicit lifetimes. My question is why did they do so in the first…
0
votes
0 answers

Integration tests in Rust

Rust doc defines that an integration test is something that verifies if a library's components all work together. Is that a semantical definition of what an integration test is? I ask that because in a microservices environment where a bunch of Rust…
arun raju
  • 41
  • 5
0
votes
0 answers

How can I write a nested Cargo.toml file?

I have an experimental Rust project that has the following directory structure: My intention is to have the ability to build and run the mentioned binary executables from three directories independently. As you can see there are three Cargo.toml…
user366312
  • 16,949
  • 65
  • 235
  • 452
0
votes
1 answer

Where to put the .cargo/config.toml file in a cargo workspace?

It's stated in the Cargo Book (on page 3.6. Configuration) that when cargo is invoked from the workspace root, the .cargo/config.toml files specified for individual packages within the workspace do not get read. At present, when being invoked from…
Keyboard Penman
  • 162
  • 1
  • 11
0
votes
0 answers

How can I resolve a compilation error when using a git dependency in Cargo with Rust?

I am facing a compilation error after switching one of my dependencies from cargo.io to a GitHub using Cargo. I would appreciate your assistance in resolving this issue. Details: Language: Rust Package manager: Cargo Source Code:…
0
votes
0 answers

Failed building wheel for cryptography - cargo rustc failed with code 101 - rpi4 + debian bullseye

I'm trying to run an install script for a service that uses piwheels to build cryptography among other things. The script keeps exiting with errors, the latest being: ERROR: Could not build wheels for cryptography, which is required to install…
0
votes
1 answer

Error compiling 'diesel' while installing Sui on virtual Ubuntu machine using Rust and Cargo

It's my first public question here, I'm sorry if it lacks any information. I'm trying to install Sui install Sui on a virtual Ubuntu machine on WSL2. This is using Rust, although I'm aswell pretty new to this. Before installing Sui, I installed the…