AkhilSharma90 / rust-ethereum-project

Rust project for working with ETH - Ethereum transactions with Rust on Ganache and also deploy smart contracts :)
13 stars 2 forks source link

error: Error: "solc": No such file or directory (os error 2) on project compile #1

Open vishalkale151071 opened 1 year ago

vishalkale151071 commented 1 year ago
pub async fn compile(root: &str) -> Result<ProjectCompileOutput<ConfigurableArtifacts>> {
    // Create path from string and check if the path exists
    let root = PathBuf::from(root);
    if !root.exists() {
        return Err(eyre!("Project root {root:?} does not exists!"));
    }

    // Configure `root` as our project root
    let paths = ProjectPathsConfig::builder()
        .root(&root)
        .sources(&root)
        .build()?;

    // Create a solc ProjectBuilder instance for compilation
    let project = Project::builder()
        .paths(paths)
        .set_auto_detect(true) // auto detect solc version from solidity source code
        .no_artifacts()
        .build()?;

    // Compile project
    let output = project.compile()?;
    println!("{:?}", output);

    // Check for compilation errors
    if output.has_compiler_errors() {
        Err(eyre!(
            "Compiling solidity project failed: {:?}",
            output.output().errors
        ))
    } else {
        Ok(output.clone())
    }
}
let project = common::compile("contracts/").await?;

Error

running 1 test
Error: "solc": No such file or directory (os error 2)

Location:
    tests/common/mod.rs:33:18
test add_notice ... FAILED

failures:

failures:
    add_notice
SkyWarrior123 commented 6 months ago

Hey I think so your path to the project is not right. Maybe configure the path and re-run it again.