Skip to content

bug(forge build): failed to read artifact source error when previously built source file is removed #9068

Closed
@frolic

Description

@frolic

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 "

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions