[Ethereum] Importing files from an “outside” folder

importsolcsolidity

I am trying to import files from a relative path outside of my Truffle-project folder:

import '../../../common/solidity/contracts/token/ERC20/BurnableToken.sol';
import '../../../common/solidity/contracts/token/ERC20/MintableToken.sol';

But when I compile with solc.exe, I get the error File outside of allowed directories.

BTW, I have no idea how come solc.exe has any knowledge of my Truffle-project folder.

In any case, checking the docs, I found the following related information:

Note that solc only allows you to include files from certain directories: They have to be in the directory (or subdirectory) of one of the explicitly specified source files or in the directory (or subdirectory) of a remapping target. If you want to allow direct absolute includes, just add the remapping =/.

But I fail to understand the meaning of just add the remapping =/.

Can anybody please shed some light on this statement?

How exactly can I import those two files correctly?

Thank you!!!

Best Answer

I got the same problem, the only workaround I have found is to pass the ..=.. argument to solc, so it will correctly interpret the paths.

So my layout is:

├── artifacts
├── contr
│   └── A.sol
└── somedir
    └── B.sol

contracts/A.sol:

...
import "../somedir/B.sol";
...

And I run solc from the root dir in the following way:

solc --abi --bin contr/A.sol -o artifacts --overwrite ..=..
Related Topic