Skip to content

bug(forge script): failed to read artifact source with lib dependencies that include files without a matching contract name #6572

@thedavidmeister

Description

@thedavidmeister

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions