We started seeing CI builds break for flex-voting (as well as other internal projects) a few days ago. The errors happened during the forge test step:
Run forge test
2024-11-19T15:32:25.463715Z ERROR foundry_compilers_artifacts_solc::sources: error="/home/runner/work/flexible-voting/flexible-voting/lib/openzeppelin-contracts/contracts/utils/math/SafeCast.sol": No such file or directory (os error 2)
Error: failed to resolve file: "/home/runner/work/flexible-voting/flexible-voting/lib/openzeppelin-contracts/contracts/utils/math/SafeCast.sol": No such file or directory (os error 2); check configured remappings
--> /home/runner/work/flexible-voting/flexible-voting/src/FlexVotingClient.sol
@openzeppelin/contracts/utils/math/SafeCast.sol
Weirdly, we were never able to reproduce this locally. However, we resolved it in CI by pinning foundry to e649e62f125244a3ef116be25dfdc81a2afbaf2a in our workflow yaml, as seen here.
This morning we tried to reproduce the issue in a clean repo. We found that the issue requires:
If the remapping is removed from the foundry.toml the issue is fixed -- forge test is able to run again in CI.
Open questions at this point:
How is the code able to compile if there are no remappings? import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol"; should not compile without a remapping, but it does.
Why are the remappings breaking CI?
What changed in foundry to cause this to happen? Nothing obvious stands out in the diff.
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (25cc1ac 2024-11-21T00:22:12.782328000Z)
What command(s) is the bug in?
forge test
Operating System
Linux
Describe the bug
TLDR minimal reproduction here
I commented on this in another issue yesterday.
We started seeing CI builds break for flex-voting (as well as other internal projects) a few days ago. The errors happened during the
forge test
step:Weirdly, we were never able to reproduce this locally. However, we resolved it in CI by pinning foundry to e649e62f125244a3ef116be25dfdc81a2afbaf2a in our workflow yaml, as seen here.
This morning we tried to reproduce the issue in a clean repo. We found that the issue requires:
forge install
ing a library like OZIf the remapping is removed from the foundry.toml the issue is fixed --
forge test
is able to run again in CI.Open questions at this point:
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
should not compile without a remapping, but it does.Thanks for your help!