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!!!

  • 1
    Did you ever figure this out? Jul 24, 2018 at 2:44
  • 1
    @ShawnTabrizi: Yes I did. Don't "mess with the system", just follow Truffle project structure, i.e., all contracts under contracts folder, all tests under test folder, etc. Jul 24, 2018 at 7:57
  • @ShawnTabrizi: Yes, you need to run solc from a path which is a parent of all the source files in your project. Nov 26, 2018 at 18:59

1 Answer 1


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


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 ..=..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.