compiler remappings fails if same name path
See original GitHub issueEnvironment information
brownie
Version: 1.12.1ganache-cli
Version: x.x.xsolc
Version: x.x.x- Python Version: 2.7.17 or 3.6.9
- OS: Ubuntu 18.04.5 LTS
What was wrong?
- forked ESD
- init new brownie dir
- moved contracts
- ESD uses truffle npm style imports so need to perform remappings
- install packages:
brownie pm install OpenZeppelin/openzeppelin-contracts@2.5.1
brownie pm install uniswap/uniswap-v2-core@1.0.1
brownie pm install uniswap/uniswap-lib@2.1.0
- set remappings:
remappings:
- "@openzeppelin=OpenZeppelin/openzeppelin-contracts@2.5.1"
- "@uniswap/lib=uniswap/uniswap-lib@1.1.2"
- "@uniswap/v2-core=uniswap/uniswap-v2-core@1.0.1"
- error on compile
contracts/oracle/Oracle.sol:21:1: ParserError: Source "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol" not found: File outside of allowed directories.
import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol';
If I flip the two uniswap remappings, the 2nd one always fails. eg)
remappings:
- "@openzeppelin=OpenZeppelin/openzeppelin-contracts@2.5.1"
- "@uniswap/v2-core=uniswap/uniswap-v2-core@1.0.1"
- "@uniswap/lib=uniswap/uniswap-lib@1.1.2"
will produce errors
contracts/mock/MockUniswapV2PairTrade.sol:20:1: ParserError: Source "uniswap/uniswap-lib@1.1.2/contracts/libraries/FixedPoint.sol" not found: File not found.
How can it be fixed?
regex? it appears the remapping ignores the info after the /
so uniswap/lib
and uniswap/v2-core
are just treated identically. the 2nd entry will always fail.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Import Path Resolution — Solidity 0.8.17 documentation
The compiler will only issue an error if the source unit name passed to the Host Filesystem Loader represents an existing path when...
Read more >Compiling Contracts — Brownie 1.18.0 documentation
If one or more contracts are unable to compile, Brownie raises an exception with ... Brownie automatically ensures that all remapped paths are...
Read more >Getting compiler error when trying to verify a contract ...
I've tried: Importing libraries with Brownie package manager; Importing libraries with npm and using relative paths; All kinds of different ...
Read more >Documentation - Module Resolution - TypeScript
If that didn't work and if the module name is non-relative (and in the ... The TypeScript compiler supports the declaration of such...
Read more >ProjectPathsConfig in ethers::solc - Rust - Docs.rs
Returns the first library that is an ancestor of the given file . ... has this remapping: @aave/=@aave/ (name:path) so contracts can be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Totally reproducing:
the above works, but if you remap as just
i.e. if 2 remappings have the same path prefix, it’s compiler errors “File not found” all over the place, like
Thanks for the workaround, I’ll have a look here shortly.
For reference: https://docs.soliditylang.org/en/latest/using-the-compiler.html#path-remapping