-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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(config
): Error: Could not read source code for analysis
w/ remappings
#2915
Comments
So it seems like it is because of the way the remappings are set up, but I'm still investigating exactly what happens. Essentially, each of your packages has a remapping for itself. I think this is because all the packages depend on each other somehow, so you need to have all of the remappings defined in case the dependency uses it, correct? In any case, if you build e.g. the package |
Changing up the remappings a bit makes it sort of work, but the report is very cluttered because none of the sub-packages are actually dependencies, it just looks at it as one big source tree. Changing [profile.default]
root = "."
libs = ['../../node_modules/', '../utils', '../fuse']
tests = "./src/tests"
ffi = true
verbosity = 3
remappings = [
'@sense-finance/v1-utils=../utils',
'@sense-finance/v1-core/=../core',
'@sense-finance/v1-fuse/=../fuse',
'@rari-capital/solmate=../../node_modules/@rari-capital/solmate',
'@openzeppelin/contracts=../../node_modules/@openzeppelin/contracts',
'ds-test/=./src/tests/test-helpers/'
] Makes it get past the error. I couldn't get the tests to run without failing though so unsure how valid the report is |
Thanks so much for investigating the issue!
I have then "fixed" the other .toml files (following the same logic) and the error is gone but I got a new one:
|
Can you post the tomls? Some parts of the toml are very important here since a misconfiguration leads to recursion in your repository |
Here they are!
|
Note: we currently run it from the root; otherwise, the coverage reporting cannot find our contracts. This may be related to foundry-rs/foundry#2915 . Also, we add flags to coveralls in an attempt to separate the reports.
Note: we currently run it from the root; otherwise, the coverage reporting cannot find our contracts. This may be related to foundry-rs/foundry#2915 . Also, we add flags to coveralls in an attempt to separate the reports.
…, improve dependabot triggers (#669) * fix(ci): Dependabot workflow should only trigger for select branches * feat(ci): Verify mgv cli can start as part of checks * fix(ci): Make coveralls use actual HEAD commit * The checkout of the push branch may not actually check out the GITHUB_SHA that triggered the workflow, a newer one may be checked out instead. We retrieve the right one by using git. * feat(ci): Add solidity code coverage to push trigger * Note: we currently run it from the root; otherwise, the coverage reporting cannot find our contracts. This may be related to foundry-rs/foundry#2915 . Also, we add flags to coveralls in an attempt to separate the reports.
@fedealconada sorry for taking so long, I had a look, and one thing that's obvious is that this setup uses circular dependencies, (core imports from fuse, fuse imports from core) I checked the solc compilerinput which looks ok, there's something weird with the output however because it contains duplicate entries for I wasn't able to find the root cause for this but it's definitely related to the relative imports, perhaps in combination with circular setup there are some weird edge cases... however I was able to resolve this by tuning the remappings and point to the
after I replaced the imports in the sol files, the issue was resolved |
Hey @mattsse , thanks a ton for the follow up! I've just tried what you suggested (changing the re-mappings and replacing imports on the sol files) but I'm getting the same error as before:
Just to double check, I pushed the changes on this branch. This is the commit with the |
Any follow up on this @mattsse ? :) |
Thanks for reporting this @fedealconada. Another data-point here. I'm working on a project that was seeing the same "could not read source code" error when I ran I eventually got EDIT: see above |
@mattsse we finally got this fixed. Not sure exactly why, but seems like our remappings in the |
Another data point here. In our case we don't have any circular dependencies, the repo imports dependencies from foundry.toml in the root directory: [profile.default]
solc = "0.8.17"
bytecode_hash = "none"
optimizer_runs = 1_000_000
remappings = ["@openzeppelin/=lib/openzeppelin-contracts/contracts/", "v3-core/=lib/v3-core"]
match_path = "test/unit/*.sol"
verbosity = 3 Also, doing |
when Kernel is used as a dependency on a project, that project's forge coverage might fail to run because of a dependency resolution issue when relative import paths are used Relevant Foundry issue: foundry-rs/foundry#2915
when Kernel is used as a dependency on a project, that project's forge coverage might fail to run because of a dependency resolution issue when relative import paths are used Relevant Foundry issue: foundry-rs/foundry#2915
when Kernel is used as a dependency on a project, that project's forge coverage might fail to run because of a dependency resolution issue when relative import paths are used Relevant Foundry issue: foundry-rs/foundry#2915
When importing Flexible Voting into another repository, the forge coverage tool was failing with the error: "Could not read source code for analysis" linked to the imports of interface files from the FlexibleVotingClient contract. While the non-relative imports work fine in the context of this repo, and even in the context of running tests normally when used as an import, they cause an issue for the coverage tool. It's unclear if this is a bug with foundry or something with our configuration. Regardless, the easiest fix is simply to use relative imports, which we do here. Read more about the issue here: foundry-rs/foundry#2915
When importing Flexible Voting into another repository, the forge coverage tool was failing with the error: "Could not read source code for analysis" linked to the imports of interface files from the FlexibleVotingClient contract. While the non-relative imports work fine in the context of this repo, and even in the context of running tests normally when used as an import, they cause an issue for the coverage tool. It's unclear if this is a bug with foundry or something with our configuration. Regardless, the easiest fix is simply to use relative imports, which we do here. Read more about the issue here: foundry-rs/foundry#2915
when Kernel is used as a dependency on a project, that project's forge coverage might fail to run because of a dependency resolution issue when relative import paths are used Relevant Foundry issue: foundry-rs/foundry#2915
It's been a while but I'm facing again this issue, any hint on this @mattsse? |
me too. I'm positive that we don't have circular dependencies, just submodules which we import from |
A hint for someone who might be researching similar issue: in my case the issue was indeed in remappings but related to OS case-sensitivity, all worked well on macOS but failed in CI on Ubunutu. Re-check the cases of your remappings, this might help |
remappings
): Error: Could not read source code for analysis
remappings
): Error: Could not read source code for analysis
config
): Error: Could not read source code for analysis
w/ remappings
The coverage issue is related to optimizer being disabled, see #8840 (comment) |
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (4e11d1f 2022-08-24T00:12:55.883067Z)
What command(s) is the bug in?
forge coverage
Operating System
macOS (Intel)
Describe the bug
After running
forge coverage
on this directory I'm getting the following message:We are using
yarn
as dependency manager and we are usingyarn workspaces
to handle multiple packages on the same repo.The text was updated successfully, but these errors were encountered: