-
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
): file paths not resolved if submodule specifies root path remappings
#3440
bug(config
): file paths not resolved if submodule specifies root path remappings
#3440
Comments
suffering from the same exact issue. |
this is a general problem with absolute import paths. you can fix this by using relative paths for contracts you import from folders like script or test, or simply overwrite the remapping. I'd recommend against remappings for folders in the same project. |
ref #1855 |
Just bumped into this issue while installing @mds1's library solidity-generators. I also have absolute import paths, and I want to counter @mattsse's suggestion from above that we should simply use relative paths. Relative paths can get really ugly and hard to maintain in complex projects; several Foundry users use absolute paths because of the aforementioned reason. |
@PaulRBerg 🤝🤝🤝 @mattsse, I can't really help atm with the MR, but many devs that come from TypeScript environment are used to path aliases and I cannot find any con in using them in the smart contracts as well. |
Don't think this issue should have been closed? mds1/solidity-generators#2 was related but it didn't fix the issue with Foundry itself. |
Huh interesting. I guess because I opened this issue originally, a PR from a repo in my namespace was able to close it? Either way, re-opening it now |
I started experiencing the same issue when I upgrade In my particular case everything was working fine with foundry commit 3d5f038. |
For future reference: when @mattsse said this:
He was referring to set one or more of the following remappings in your project: script/=script/
src/=src/
test/=test/ You only have to do this for those remappings that are overwritten by your dependencies. |
I guess my #4597 is this same issue. I just want to add that relative imports in the dependent project suffer from this problem (which seems to contradict some earlier suggestions in this thread). I believe solc resolves those relative paths into relative paths, relative to the project root. Thus It seems to me that relative remappings.txt in |
This is exactly what #5397 fixes, PTAL. It scopes remappings in e.g. |
@onbjerg that sounds basically perfect to me, does it introduce the issue i saw with relative paths though? namely that some type can be defined in two commit-identical dependencies and treated by solidity as different types? |
@Evalir @onbjerg actually i'm still getting quite a lot of errors that mean i can't compile based on import resolving
The only way I can see to fix these is to install the deps globally in the root of the project, they aren't being picked up by the submodule as the submodule's own deps I think this issue is still unresolved (i ran foundryup just now)
|
It also looks like the same issue as relative paths has now been introduced for remapped paths @onbjerg types from deps on the same git commit are treated as different types
|
@aathan the problem with just saying that types should be different if they are in different folders, is that sometimes they are the same in the example i'm running into now ^^ i did start going down the road of manually differentiating between then what you run into is "can't automatically convert between types" which involves wrapping and unwrapping every type at every function boundary. If you write some library that wants its type as an input/output then you can't use that library in two places in a single repo. now, if these in this case though, the exact same commit of a dependency is being treated as "already declared" simply because two different deps use it perhaps if we were to use the preprocessing idea that you are suggesting, all the nested deps could be "hoisted" to the root |
kk, so i did some experimenting comparing
what I found was, that i had added Running
All the other recent versions of forge seem to have corrupt archives so i can't test them. |
Related: #5447 |
@PaulRBerg in my case some of what i'm seeing could potentially be #5447 as i do have multiple instances of the same dep in my tree |
Adding remapping to avoid the foundry bug: foundry-rs/foundry#3440
config
): file paths not resolved if submodule specifies root path remappings
Component
Forge
Describe the feature you would like
Steps to reproduce:
forge install
forge build
, it fails with the below errorlib/forge-test-my-dep
, openfoundry.toml
and comment out the remappingsforge build
, it passesAdditional context
No response
The text was updated successfully, but these errors were encountered: