-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug(forge script
): failed to read artifact source
with lib dependencies that include files without a matching contract name
#6572
Comments
+1 on this. Also receiving the same error. Using forge 0.2.0 as well |
For context, I was able to fix this error by changing the imports in my dependency contracts. Switching from So im assuming this bug has to do with the way remappings are handled in scripts? |
same. haven't found a fix yet. |
afaics the relative paths doesn't make a difference for me because i think i'm already using relative paths everywhere actually i was seeing the error without any imports and simply trying to run a console log in an empty script file |
This is a script where I get the error // SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "forge-std/Script.sol";
interface IMainFactory {
function test() external;
}
contract Mint2Script is Script {
function run() external {
IMainFactory mainFactory = IMainFactory(0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0); // in anvil
mainFactory.test();
}
} I run it as and get
P.S. error is thrown only if I do external call of mainFactory.test(); |
Also seeing this issue, cc @mattsse, same cause and fix described by @thedavidmeister above A more complex repro can be found here, notice the empty contracts added in |
has some issue |
had similar issue running op-stack deployment scripts. |
I have same issue after founryup. |
I reinstalled foundry since I believe I had an outdated version from last year and that did the trick. Just head over to installation on foundry book and reinstall and that should help. |
this works for me |
so an annoyable bug. With no fix from the team. |
Any time I get an error with artifacts, the first step I take is forge clean followed by forge build |
forge script
with lib dependencies that include files without a matching contract nameforge script
with lib dependencies that include files without a matching contract name
Hi all, having a cloneable minimal reproduction repo would be greatly appreciated to help narrow this down. I'm unable to reproduce it with this setup: https://github.com/zerosnacks/foundry-bug-6572-repro I created based on the description of the issue. Any pointers are appreciated @thedavidmeister. It imports files from https://github.com/zerosnacks/foundry-bug-6572-repro-lib/tree/master/src containing just constants and errors |
forge script
with lib dependencies that include files without a matching contract nameforge script
): failed to read artifact source
with lib dependencies that include files without a matching contract name
This worked for me |
|
using forge clean worked for me |
Did this and it fixed it for me. Reinstalling foundry didnt |
Noticed the bug popped up when changing pathnames and them sticking but not updating in foundry.
This resolved the issue for me |
Hi. I had the same problem and solved it by clearing foundry's cache with the following command: forge clean See forge-clean. |
i can confirm |
This worked for me. thanks a lot🙏 |
@zhiqiangxu could you provide a way to reproduce this issue consistently? thank you! |
Sorry 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. |
we're going to close this optimistically as were not able to reproduce it and looks like |
Component
Forge
Have you ensured that all of these are up to date?
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 likeThis error can be worked around by adding an empty contract like
contract ErrBitwise {}
in the file that forge is complaining aboutThe text was updated successfully, but these errors were encountered: