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.33k stars 1.76k forks source link

breaking(`nightly`): `Ambiguous import. Multiple matching files found inside base path and/or include paths` #9365

Closed 0xTimepunk closed 1 day ago

0xTimepunk commented 1 day ago

Component

Forge

Have you ensured that all of these are up to date?

What version of Foundry are you on?

nightly

What command(s) is the bug in?

forge build

Operating System

None

Describe the bug

Recent nightly from 2 days ago giving errors both on local and on CI

You can check a run https://github.com/superform-xyz/SuperVaults/actions/runs/11918496623/job/33216055316

If you run this repo on foundryup -C 9d74675bae8bfbd83428ff1343cbe2ae206c3383 the error won't exist

Note: this is urgent as it is breaking all of our CI runs

zerosnacks commented 1 day ago

Source of the error in solc: https://github.com/ethereum/solidity/blob/b0d991bd4b3bc2d48d40029c3303f67f604d7cc5/libsolidity/interface/FileReader.cpp#L128-L135

"/home/runner/work/SuperVaults/SuperVaults/lib/forge-std/src/Test.sol"

"/home/runner/work/SuperVaults/SuperVaults/lib/superform-core/lib/forge-std/src/Test.sol"

Possibly related to recent changes in https://github.com/foundry-rs/compilers? cc @klkvr / @DaniPopes / @grandizzy

grandizzy commented 1 day ago

yeah, was able to confirm was working before compilers update in https://github.com/foundry-rs/foundry/pull/8668 Workaround until a fix would be to change root prj remapping to 'forge-std/=lib/superform-core/lib/forge-std/src/', https://github.com/superform-xyz/SuperVaults/blob/main/foundry.toml#L20

grandizzy commented 1 day ago

pretty sure the right fix would be the one for https://github.com/foundry-rs/foundry/issues/9146 which should just ignore remappings from deps if already present in project root remapping

davidlaprade commented 1 day ago

+1

I believe this is the source of the CI errors we're seeing on FlexVoting as well. CI was passing until nightly-e649e62, failing after. Pinning to e649e62f fixes it.

grandizzy commented 1 day ago

I believe this is the source of the CI errors we're seeing on FlexVoting as well. CI was passing until nightly-e649e62, failing after. Pinning to e649e62 fixes it.

I am not sure is the same issue, I am not able to replicate the failure locally with master, did you try with latest nightly and still fails? thank you

davidlaprade commented 1 day ago

I can't reproduce our issue locally either, even after foundryup and forge clean. Happy to open another issue if you think this is different @grandizzy! But, yes, latest nightly still fails

klkvr commented 1 day ago

The root cause is that solc does not receive the forge-std/Test.sol file in input. This is likely happening due to parsing failure which results in our resolver losing data about file imports.

@DaniPopes I'm seeing such errors related to comments in unusual places in logs:

   --> /Users/klkvr/repos/SuperVaults/test/SuperVault.t.sol:659:31
    |
659 |                         false,
    |                               ^ expected one of 11 possible tokens
660 |                         /// @dev placeholder value, not used
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unexpected token
    |
    = note: created at /Users/klkvr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/solar-parse-0.1.0/src/parser/expr.rs:213:25,
            emitted at /Users/klkvr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/foundry-compilers-0.12.1/src/resolver/parse.rs:67:61
grandizzy commented 1 day ago

I can't reproduce our issue locally either, even after foundryup and forge clean. Happy to open another issue if you think this is different @grandizzy! But, yes, latest nightly still fails

I suspect that's a CI caching issue, on a successful run the missing deps are found and installed https://github.com/ScopeLift/flexible-voting/actions/runs/11821757268/job/32937233608#step:4:9 whereas on the failure it is starts building directly hence no file present in path https://github.com/ScopeLift/flexible-voting/actions/runs/11821757268/job/33208886192#step:4:9 @klkvr do you think this is the same issue as the original one? thanks

klkvr commented 1 day ago

It is not the same issue but probably also related to path resolution, unsure what exactly is happening there without a repro

grandizzy commented 1 day ago

👍 @davidlaprade please retry with tomorrow's build (that should include fix for this issue) and open a ticket if you still see the ptoblem. Thank you.

davidlaprade commented 1 day ago

Thanks! Will do

zerosnacks commented 1 day ago

A nightly with a fix has been released: https://github.com/foundry-rs/foundry/releases/tag/nightly-fb5f0e1c4d9b9b0861be3e3bd07963524c5ac08e