question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

File outside of allowed directories error.

See original GitHub issue

Hi, I was trying to flat a very simple contract just to test the library and python requirements:

pragma solidity ^0.4.24;

import "../node_modules/openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "../node_modules/openzeppelin-solidity/contracts/token/ERC20/StandardBurnableToken.sol";

contract myToken is StandardBurnableToken, Ownable {
    string public name = "";
    string public symbol = "";
    uint8 public decimals = 18;
}

and I get this:

solidity_flattener contracts/MyToken.sol
contracts/MyToken.sol:3:1: Error: Source "node_modules/openzeppelin-solidity/contracts/ownership/Ownable.sol" not found: File outside of allowed directories.
import "../node_modules/openzeppelin-solidity/contracts/ownership/Ownable.sol";
^-----------------------------------------------------------------------------^
contracts/MyToken.sol:4:1: Error: Source "node_modules/openzeppelin-solidity/contracts/token/ERC20/StandardBurnableToken.sol" not found: File outside of allowed directories.
import "../node_modules/openzeppelin-solidity/contracts/token/ERC20/StandardBurnableToken.sol";
^---------------------------------------------------------------------------------------------^
Traceback (most recent call last):
  File "/Users/andreaspeziale/Repository/my-token/env/bin/solidity_flattener", line 4, in <module>
    flattener.core.main()
  File "/Users/andreaspeziale/Repository/my-token/env/lib/python3.7/site-packages/flattener/core.py", line 97, in main
    solc_proc.check_returncode()
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 409, in check_returncode
    self.stderr)
subprocess.CalledProcessError: Command '['solc', '--ast', 'contracts/MyToken.sol']' returned non-zero exit status 1.

The $ truffle compile works well.

Thank you for the help.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
andreafspezialecommented, Aug 15, 2018

@XertroV Yes i noticed it. Actually I don’t know maybe I’m missing something else but it worked. Give a look to those two tracebacks. The first one worked the second one nope and the diff is only the solc prefix.

(env) ➜  spaghetti-sale git:(master) solidity_flattener --solc-path="solc --allow-paths $PWD/node_modules/zeppelin-solidity/ zeppelin-solidity=$PWD/node_modules/zeppelin-solidity" contracts/SpaghettiCoin.sol --output $PWD/flattened/SpaghettiCoin.sol

(env) ➜  spaghetti-sale git:(master) solidity_flattener --solc-path="--allow-paths $PWD/node_modules/zeppelin-solidity/ zeppelin-solidity=$PWD/node_modules/zeppelin-solidity" contracts/SpaghettiCoin.sol --output $PWD/flattened/SpaghettiCoin.sol
unrecognised option '--allow-paths /Users/andreaspeziale/Repository/learning/spaghetti-sale/node_modules/zeppelin-solidity/ zeppelin-solidity=/Users/andreaspeziale/Repository/learning/spaghetti-sale/node_modules/zeppelin-solidity'
Traceback (most recent call last):
  File "/Users/andreaspeziale/Repository/learning/spaghetti-sale/env/bin/solidity_flattener", line 4, in <module>
    flattener.core.main()
  File "/Users/andreaspeziale/Repository/learning/spaghetti-sale/env/lib/python3.7/site-packages/flattener/core.py", line 97, in main
    solc_proc.check_returncode()
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 409, in check_returncode
    self.stderr)
subprocess.CalledProcessError: Command '['solc', '--allow-paths /Users/andreaspeziale/Repository/learning/spaghetti-sale/node_modules/zeppelin-solidity/ zeppelin-solidity=/Users/andreaspeziale/Repository/learning/spaghetti-sale/node_modules/zeppelin-solidity', '--ast', 'contracts/SpaghettiCoin.sol']' returned non-zero exit status 1.
(env) ➜  spaghetti-sale git:(master)
Traceback (most recent call last):
  File "/Users/andreaspeziale/Repository/learning/spaghetti-sale/env/bin/solidity_flattener", line 4, in <module>
    flattener.core.main()
  File "/Users/andreaspeziale/Repository/learning/spaghetti-sale/env/lib/python3.7/site-packages/flattener/core.py", line 97, in main
    solc_proc.check_returncode()
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 409, in check_returncode
    self.stderr)
subprocess.CalledProcessError: Command '['solc', '--allow-paths /Users/andreaspeziale/Repository/learning/spaghetti-sale/node_modules/zeppelin-solidity/ zeppelin-solidity=/Users/andreaspeziale/Repository/learning/spaghetti-sale/node_modules/zeppelin-solidity', '--ast', 'contracts/SpaghettiSale.sol']' returned non-zero exit status 1.

(env) ➜  spaghetti-sale git:(master)

unrecognised option '--allow-paths...

Have a nice day!

1reaction
XertroVcommented, Aug 14, 2018

@andreafspeziale glad you got it working.

It’s weird that adding solc to the start worked… I wouldn’t expect it to given this line: https://github.com/BlockCatIO/solidity-flattener/blob/53b01d1db12a5ef4dfe35adf4bd6e4f73d90d0f8/flattener/core.py#L93

In any case 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

File outside of allowed directories issue #2742 - GitHub
I have zeppelin as a submodule, and I am trying to import a solidity contract from inside of the zeppelin submodule. solc is...
Read more >
File outside of allowed directories. [solidity/solc]
I tried creating a symlink in the contracts directory and running vim from the same directory, and still get the same warning. I...
Read more >
Brownie: CompilerError: File outside of allowed directories
it doesn't find aggregatorV3interface.sol. Have you installed it? try pip3 install @chainlink/contracts or npm install @chainlink/contracts.
Read more >
Help needed - File outside of allowed directories error
Whenever I try to run a script using brownie, I keep getting an error from my contract about the openzeppelin and chainlink imports....
Read more >
ethereum/solidity - Gitter
I'm trying to compile with solc but receiving this error in relation to my paths: ... not found: File outside of allowed directories....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found