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? Commented 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. Commented 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. Commented Nov 26, 2018 at 18:59

2 Answers 2


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

It is clearer in the post v0.5 documentation where it says:

things like import "/etc/passwd"; only work if you add /=/ as a remapping

This solves the access problem because the side effect of specifying a remapping is that it authorizes access to all the subdirectories of the target, in this case, the target being /, the whole file tree becomes authorized

Another solution may be to specify on the command line:

--allow-paths /

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.