foundry
foundry copied to clipboard
Forge: duplicate filename artifact location collisions
Component
Forge
Have you ensured that all of these are up to date?
- [X] Foundry
- [X] Foundryup
What version of Foundry are you on?
forge 0.2.0 (d431f74 2024-04-27T00:17:17.280985407Z)
What command(s) is the bug in?
forge build
Operating System
Linux
Describe the bug
I have two directories with a contract with the same name
-
src/A/C.sol
-
src/B/C.sol
Example scenario: developing a /v2/
rewrite of a /v1/
solution.
-
forge build --force
-
out/A/C.sol/C.json
-
out/B/C.sol/C.json
-
- modify
A/C.sol
→forge build
-
out/C.sol/C.json
← corresponds to A
-
- modify
B/C.sol
→forge build
-
out/C.sol/C.json
← now corresponds to B
-
Incremental builds should either rely on the cached artifact layout, or the artifacts should all be nested inside some fully-expanded hashed layout, like out/${hash(absolute path)}/{file}.sol/{name}.json
.
solidity-files-cache.json
reflects change (2) but becomes bugged after (3) as there are now 2 cached artifacts with the same path but different sources.
IMO, these file locations should be somewhat predictable. The current solution of creating minimal directories when duplicates exist is weird.
@klkvr I assume this is an edge case we're missing during caching preprocess
Not sure how closely related but a similar issue exists for duplicates when multiple compiler versions are used https://github.com/gakonst/ethers-rs/issues/1995