Skip to content

Unable to run "forge test" in a package that depends upon another package in a monorepo because a library artifact is not found #11593

@PaulRBerg

Description

@PaulRBerg

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

v1.3.5-nightly

What version of Foundryup are you on?

v1.3.0

What command(s) is the bug in?

forge test

Operating System

macOS (Apple Silicon)

Describe the bug

Problem

forge test fails to find library artifacts for workspace dependencies, while forge build works fine.

Error:

Error: wasn't able to find artifact for library Helpers at ../node_modules/@sablier/lockup/src/libraries/Helpers.sol

Structure

monorepo/
├── foundry.toml              # Base config: "@sablier/=../node_modules/@sablier/"
├── node_modules/@sablier/
│   └── lockup -> ../../lockup # Bun workspace symlink
├── lockup/                   # Workspace package with Helpers library
│   └── out/Helpers.sol/Helpers.json ✅ Artifact exists
└── airdrops/                 # Workspace package depending on lockup
    ├── foundry.toml          # Inherits base config
    └── tests/                # Tests fail to link Helpers library

Dependency

The airdrops package depends upon the lockup package like so:

"@sablier/lockup": "workspace:*"

Note

Switching to a remote version of the package, e.g. github:sablier-labs/lockup#staging, doesn't solve the issue.

Root Cause

I think the root cause is that the test runner's library linking can't resolve artifacts through Bun workspace symlinks, even though compilation works.

Possible related issue: #11587

Repro

  1. Clone https://github.com/sablier-labs/evm-monorepo
  2. bun install
  3. cd airdrops
  4. forge test

The tests in all other packages work.

Environment

  • bun v1.2.21 with workspaces enabled
  • forge v1.3.5-nightly

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions