foundry: bug(`forge script`): `failed to read artifact source` with lib dependencies that include files without a matching contract name
Component
Forge
Have you ensured that all of these are up to date?
- Foundry
- Foundryup
What version of Foundry are you on?
forge 0.2.0 (0ae39ea 2023-12-11T00:27:32.487222000Z)
What command(s) is the bug in?
forge script
Operating System
macOS (Apple Silicon)
Describe the bug
Running forge script in a repo that has a dependency with .sol files that don’t contain a contract (e.g. the file contains only error definitions or constants) results in an error like
thedavidmeister@davids-iMac polytrade % forge script scripts/OrderBookNPE2.s.sol
[⠒] Compiling...
No files changed, compilation skipped
Error:
failed to read artifact source file for `lib/rain.interpreter/src/error/ErrBitwise.sol:ErrBitwise`
Context:
- Error #0: failed to read from "/Users/thedavidmeister/Code/polytrade/src/error/ErrBitwise.sol": No such file or directory (os error 2)
- Error #1: No such file or directory (os error 2)
This error can be worked around by adding an empty contract like contract ErrBitwise {} in the file that forge is complaining about
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 28 (3 by maintainers)
Any time I get an error with artifacts, the first step I take is forge clean followed by forge build
Hi. I had the same problem and solved it by clearing foundry’s cache with the following command:
See forge-clean.
using
worked for me
No fix?
@gakonst @Evalir
had similar issue running op-stack deployment scripts.
No matching artifact foundrevert to an early foundry version fixed itfoundryup -v nightly-5b7e4cb3c882b28f3c32ba580de27ce7381f415aSorry I can’t,last time when I was debugging from source code, the issue suddenly went away, I guess it’s a random bug with cache. That’s all I can say.
forge cleandoesn’t work for me.It seems a random bug, but is now always showing up on my machine:
Clearly the correct path should be
L2/interfaces/ICrossL2Inbox.sol, but it’s looking forL2/ICrossL2Inbox.sol.I’ve already upgraded to the latest version:
Noticed the bug popped up when changing pathnames and them sticking but not updating in foundry.
This resolved the issue for me
This worked for me
so an annoyable bug. With no fix from the team.