foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.31k stars 1.75k forks source link

cast failing to compile #464

Closed totlsota closed 2 years ago

totlsota commented 2 years ago

OS:

Mac 11.5

Install command

cargo install --git https://github.com/gakonst/foundry --bin cast  

Issue:

cast fails to compile with error below

forge binary builds and runs fine

Error trace


Compiling ethers-solc v0.1.0 (https://github.com/gakonst/ethers-rs#77dcccb7)
error[E0023]: this pattern has 3 fields, but the corresponding tuple variant has 4 fields
   --> .cargo/git/checkouts/ethers-rs-c3a7c0a0ae0fe6be/77dcccb/ethers-solc/src/resolver.rs:426:53
    |
426 |                     SourceUnitPart::PragmaDirective(_, pragma, value) => {
    |                                                     ^  ^^^^^^  ^^^^^ expected 4 fields, found 3
    |
   ::: .cargo/git/checkouts/solang-98203f5abd7a90ef/747e524/solang-parser/src/pt.rs:58:21
    |
58  |     PragmaDirective(Loc, Vec<DocComment>, Identifier, StringLiteral),
    |                     ---  ---------------  ----------  ------------- tuple variant has 4 fields
    |
help: use `_` to explicitly ignore each field
    |
426 |                     SourceUnitPart::PragmaDirective(_, pragma, value, _) => {
    |                                                                     +++

For more information about this error, try `rustc --explain E0023`.
error: could not compile `ethers-solc` due to previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `foundry-cli v0.1.0 (https://github.com/gakonst/foundry#c0e534c0)`, 
youngkidwarrior commented 2 years ago

It seems this change to ethers-rs is the cause

Add Location To Solidity Pragma Directive (#638)

add loc to pragma directive
PragmaDirective(Loc, Vec<DocComment>, Identifier, StringLiteral),

Here is a short term fix, until foundry guys release an official fix

  1. Open ethers-solc resolver for current install

/Users/$USER/.cargo/git/checkouts/ethers-rs-c3a7c0a0ae0fe6be/93878e4/ethers-solc/src/resolver.rs

  1. Change Line 426:

    SourceUnitPart::PragmaDirective(_, pragma, value) => {

    to

    SourceUnitPart::PragmaDirective(_, _, pragma, value) => {

  2. Run cast install command

    cargo install --git https://github.com/gakonst/foundry --bin cast

mattsse commented 2 years ago

there was a breaking change on solang-parser

fixed on ethers-rs here, https://github.com/gakonst/ethers-rs/pull/796

then needs a cargo update -p ethers here