apk190000
apk190000

Reputation: 55

How to deal with unresolved import 'concrete' issues in RUST

I am new to RUST, and I am trying to use this concrete library: https://github.com/zama-ai/concrete/tree/master/concrete. I am trying to create a simple "Hello World" in RUST to see if concrete imports correctly. I followed the instructions in the aforementioned link.

Specifically, I:

  1. Cloned the GitHub repo.
  2. Cd into concrete folder (/concrete/concrete)
  3. ran "cargo new play_with_fhe"
  4. Updated the "Cargo.toml" file with the new member "play_with_me"
[workspace]

members = [
    "concrete",
    "concrete-npe",
    "concrete-core",
    "concrete-csprng",
    "concrete-commons",
    "concrete-tasks",
    "concrete-boolean",
    "play_with_fhe",
]

[profile.bench]
opt-level = 3
debug = true
lto="fat"

[patch.crates-io]
concrete = {path="concrete"}
concrete-npe = {path="concrete-npe"}
concrete-core = {path="concrete-core"}
concrete-csprng = {path="concrete-csprng"}
concrete-commons = {path="concrete-commons"}
concrete-boolean = {path= "concrete-boolean"}
play_with_fhe = {path= "play_with_fhe"}
  1. Cd into "/concrete/concrete/play_with_fhe" and updated the "Cargo.toml" file with
[package]
name = "play_with_fhe"
version = "0.1.11"
authors = ["FHE Curious"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
concrete = "^0.1.11"
  1. Cd into /concrete/concrete/play_with_fhe_/src and created a main.rs file running a simple code:
use concrete::*;
fn main() {
    println!("Hello, world!");
}
  1. When I try compiling it with rustc main.rs, I get told that:
error[E0432]: unresolved import `concrete`
 --> main.rs:2:5
  |
2 | use concrete::*;
  |     ^^^^^^^^ maybe a missing crate `concrete`?

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.

How can I address this issue? Any advice would be appreciated.

Upvotes: 2

Views: 1739

Answers (1)

Rob Napier
Rob Napier

Reputation: 299565

Since you're trying to create your own hello world project, you don't need to clone the repository. You just need to create a project, include concrete as a dependency, and then import it. Those instructions are on the concrete page (as Stargateur notes):

% cargo new play_with_fhe
% cd play_with_fhe

Add concrete to your dependencies in Cargo.toml:

[package]
name = "play_with_fhe"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
concrete = "^0.1"   # <--- This is the only change you make. The rest is template.

Then add use cargo::* to the top of your main.rs, and build it:

% cargo build

This will install everything. For more on Cargo, see Dependencies in Rust By Example.

Note that this package likely won't build correctly unless you're on an x86 architecture. For example, it won't run on an Apple M1 without Rosetta2.

Upvotes: 3

Related Questions