Help needed - File outside of allowed directories error

Truffle
OpenZeppelin/ openzeppelin-contracts @ 3.4.0
Brownie-eth

:memo:Details
Whenever I try to run a script using brownie, I keep getting an error from my contract about the openzeppelin and chainlink imports.

I have also have the following in my brownie.config.yaml:

dependencies:

  • smartcontractkit/chainlink-brownie-contracts@1.0.2
  • OpenZeppelin/openzeppelin-contracts@3.4.0
    compiler:
    solc:
    remappings:
    • ‘@chainlink=smartcontractkit/chainlink-brownie-contracts@1.0.2’
    • ‘@openzeppelin=OpenZeppelin/openzeppelin-contracts@3.4.0’

:1234: Code to reproduce

brownie run scripts/advanced_collectible/deploy_advanced.py

Compiling contracts…
Solc version: 0.6.6
Optimizer: Enabled Runs: 200
EVM Version: Istanbul
CompilerError: solc returned the following errors:

contracts/AdvancedCollectible.sol:3:1: ParserError: Source “openzeppelin/contracts/token/ERC721/ERC721.sol” not found: File outside of allowed directories.
import “openzeppelin/contracts/token/ERC721/ERC721.sol”;
^------------------------------------------------------^

contracts/AdvancedCollectible.sol:4:1: ParserError: Source “chainlink/contracts/src/v0.6/VRFConsumerBase.sol” not found: File outside of allowed directories.
import “chainlink/contracts/src/v0.6/VRFConsumerBase.sol”;
^--------------------------------------------------------^

Looking at the errors, I think you’re just missing the @ in your imports. The error message indicates that you do this:

import "openzeppelin/contracts/token/ERC721/ERC721.sol";

while the remapping you have will only work with this:

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
2 Likes