Skip to content
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 build): failed to read artifact source error when previously built source file is removed #9068

Open
2 tasks done
holic opened this issue Oct 8, 2024 · 1 comment
Labels
C-forge Command: forge Cmd-forge-build Command: forge build T-bug Type: bug T-to-reproduce Type: requires reproduction

Comments

@holic
Copy link

holic commented Oct 8, 2024

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 (e215f3f 2024-10-08T00:25:05.208317000Z)

What command(s) is the bug in?

forge script, forge build

Operating System

macOS (Apple Silicon)

Describe the bug

I don't recall this happening before and seems to have surfaced recently. This generally happens when you are working on a .sol file, forge build, then remove the source file before building again. Forge seems to still want to find the source file by its artifact. I see this most often when switching branches where Solidity files come and go.

To fix/workaround, I have to forge clean manually, but would expect forge to be smart enough to figure this out.

running "forge script PostDeploy --broadcast --sig run(address) 0x8D8b6b8414E1e3DcfD4168561b9be6bD3bF6eC4B --rpc-url http://127.0.0.1:8545 -vvv "
[⠊] Compiling...
No files changed, compilation skipped
2024-10-08T17:37:00.688771Z ERROR foundry_compilers_artifacts_solc::sources: error="/Users/kevin/Projects/paymaster/packages/contracts/node_modules/@account-abstraction/contracts/interfaces/UserOperation.sol": No such file or directory (os error 2)
Error: Error: 
failed to read artifact source file for `/Users/kevin/Projects/paymaster/packages/contracts/node_modules/@account-abstraction/contracts/interfaces/UserOperation.sol`

Context:
- "/Users/kevin/Projects/paymaster/packages/contracts/node_modules/@account-abstraction/contracts/interfaces/UserOperation.sol": No such file or directory (os error 2)
Error running "forge script PostDeploy --broadcast --sig run(address) 0x8D8b6b8414E1e3DcfD4168561b9be6bD3bF6eC4B --rpc-url http://127.0.0.1:8545 -vvv "
@holic holic added T-bug Type: bug T-needs-triage Type: this issue needs to be labelled labels Oct 8, 2024
@zerosnacks zerosnacks changed the title forge build errors when previously built source file is removed bug(forge build): failed to read artifact source error when previously built source file is removed Oct 9, 2024
@zerosnacks zerosnacks added C-forge Command: forge Cmd-forge-build Command: forge build T-to-reproduce Type: requires reproduction and removed T-needs-triage Type: this issue needs to be labelled labels Oct 9, 2024
@zerosnacks
Copy link
Member

Related: #6572

Not marking as a duplicate as your description is more general, updated the title for better searchability.

For the time being, as you mentioned it is currently recommended to run forge clean if you run into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-build Command: forge build T-bug Type: bug T-to-reproduce Type: requires reproduction
Projects
Status: Todo
Development

No branches or pull requests

2 participants