11

I'm using vim with the syntastic plugin.

I'm getting this message:

Source "zeppelin-solidity/contracts/token/StandardToken.sol" not found: File outside of allowed directories. [solidity/solc]

when editing a .sol file in <prj-root>/contracts (as per truffle init)

zeppelin-solidity was installed by yarn add into <prj-root>/node_modules.

I tried creating a symlink in the contracts directory and running vim from the same directory, and still get the same warning.

I also tried running vim inside the node_modules directory so that the path wouldn't involve a symlink:

$ pwd                                          
/home/ravi/repo/erc20/coin/node_modules        
$ ls                                           
zeppelin-solidity                              
$ vim ../contracts/CapitalCoin.sol

How can I silence this error?

3 Answers 3

5

This could be related to the restrictions of solc. From the documentation at http://solidity.readthedocs.io/en/v0.4.21/using-the-compiler.html:

For security reasons the compiler has restrictions what directories it can access. Paths (and their subdirectories) of source files specified on the commandline and paths defined by remappings are allowed for import statements, but everything else is rejected. Additional paths (and their subdirectories) can be allowed via the --allow-paths /sample/path,/another/sample/path switch.

2
  • So in this case, the @openzeppelin is in the node_modules directory, what we should do? This setting is so annoying
    – Ender
    Jun 23, 2021 at 8:36
  • If node_modules is inside the directory you're running the compiler from (or your --base-path) it should work without this option. Otherwise add --allow-paths /path/to/your/node_modules/. Be careful with relative paths. Versions prior to 0.8.8 had several bugs related to path normalization, making --allow-paths not whitelist the right thing in some cases (#11688). Also note that this must be the actual location of the files, i.e. not containing any symlinks.
    – cameel
    Nov 28, 2021 at 18:29
2

I was able to get it to go away by placing the following into my .vimrc

let g:syntastic_solidity_solc_args = "--allow-paths"

However I'm not confident since running:

solc contracts/CONTRACT.sol --allow-paths

doesn't pass without a list.

I've tried running it with a list and denoting all:

solc contracts/CONTRACT.sol --allow-paths *

but that also fails.

I did a comma and it seems to work, though it looks improperly formatted IMO.

solc contracts/CONTRACT.sol --allow-paths *,

I followed: syntastic 4.5. Q. How can I pass additional arguments to a checker?

1
  • 1
    This worked because an empty path would whitelist everything. To specify one explicitly you could also do --allow-paths "". --allow-paths , and --allow-paths *, have the same effect because the option takes a comma-separated list of paths and a comma at the end means that you have an extra item - an empty one. This won't work any more on 0.8.8. You can use --allow-paths / instead which has the same effect but is more explicit. Note that whitelisting your whole filesystem defeats the whole point of this feature so use at your own risk.
    – cameel
    Nov 28, 2021 at 18:39
0

Alternatively you can Download "Zapplin" Lib(Size in few kbs) from github and manually place that in your project's root folder. Then try to import "StandardToken.sol" directly. I have not much experience in Truffle. But might be this can help you out.

1
  • this is my workaround when facing this issue. Unnecessary design, tho
    – Ender
    Jun 23, 2021 at 8:37

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.