I am using the ring library to provide encryption functions,but I need to generate some random numbers unrelated to encryption, and am unable to use the rand crate due to this error.
use rand::Rng;
| ^^^^ help: a similar path exists: `ring::rand`
[package]
name = "fallout_terminal"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
ring = "0.16.20"
rand = "0.8.4"
what was the full error message then? is there's a name clash, i.e. did you import other module named rand? if you have other rand symbol in scope, try add a :: prefix to the crate name, like this:
Added a prefix to the crate name, that didn't work. Here's the full error I got when running cargo build.
error[E0432]: unresolved import `rand`
--> src\main.rs:3:7
|
3 | use ::rand::Rng;
| ^^^^ help: a similar path exists: `ring::rand`
For more information about this error, try `rustc --explain E0432`.
error: could not compile `fallout_terminal` due to previous error
The error message is about a package named terminal_emulator, but the Cargo.toml you posted earlier has a package name of fallout_terminal.
If you have two packages involved, then you need to put rand in the [dependencies] of terminal_emulator. If something else is going on, please post more information, like the file tree of your entire project.
Don't edit error messages — that hides important clues. Tell us why it was the way it was. Did you rename the package between this and your earlier post?
I forgot that I renamed the package, yes. It was an attempt to see if that would effect cargo throwing the similar path error. I reverted it because that didn't work.
your Cargo.lock file doesn't agree with your Cargo.toml manifest. your package fallout_terminal has ring as one only dependency, but the Cargo.toml you posted before says you have two dependencies: rand and ring.
[[package]]
name = "fallout_terminal"
version = "0.1.0"
dependencies = [
"ring",
]
it might be possible that cargo is reading a "stale" copy of Cargo.toml, for unknown reasons. is the filesystem mounted or mapped through network? does your dev environment have some transparent caching mechanism? things like such.