Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (ac80261 2024-02-24T00:17:06.154246094Z)
What command(s) is the bug in?
forge script
Operating System
Linux
Describe the bug
Running forge script MyDeployment.sol fails with the message Error: Could not find target contract MyDeployment even though the file is clearly present and the script contract name is correct.
In my case, the real bug was calling an external library method which had been accidentally marked public/external instead of internal, causing a dynamic linkage failure, and the message "Error: Could not find target contract"
You should be able to reproduce using a library Foo { function foo() public {} } along with a contract which calls Foo.foo() and finally a deployment script which constructs the contract that uses the external lib. If you change the visibility to internal, the static binding / inlining causes the "Could not find target contract" message to go away.
This is the same error message as reported in #3076 but presumably with a different cause/solution.
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (ac80261 2024-02-24T00:17:06.154246094Z)
What command(s) is the bug in?
forge script
Operating System
Linux
Describe the bug
Running
forge script MyDeployment.solfails with the messageError: Could not find target contract MyDeploymenteven though the file is clearly present and the script contract name is correct.In my case, the real bug was calling an external library method which had been accidentally marked public/external instead of internal, causing a dynamic linkage failure, and the message "Error: Could not find target contract"
You should be able to reproduce using a
library Foo { function foo() public {} }along with a contract which callsFoo.foo()and finally a deployment script which constructs the contract that uses the external lib. If you change the visibility tointernal, the static binding / inlining causes the "Could not find target contract" message to go away.This is the same error message as reported in #3076 but presumably with a different cause/solution.