'Trying to run a Brownie Dapp in Docker

I'm trying to run my brownie dapp in a docker container, but i always have the same error and can't seem to fix it:

FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/username/.brownie/packages/OpenZeppelin/openzeppelin-> > [email protected]/contracts/access/Ownable.sol'

I cloned the OpenZepplin folder with all the contracts to the work folder of my project and then remapped it like this: dependencies:

  - OpenZeppelin/[email protected]
compiler:
solc:
remappings:
      - "OpenZeppelin/[email protected]/ = ./OpenZeppelin/[email protected]/"

But it still gives the same error, and when I compile the contract, it is clearly still using the C:/Users/username/.brownie/packages/OpenZeppelin/[email protected]/contracts folder. I know this because I tried to compile the contracts with a remapping to a non-existing folder:

remappings:
      - "OpenZeppelin/[email protected]/ = ./nothing/"

and it still compiled perfectly.

Just wondering if anybody could help me with this, and thank you in advance!



Solution 1:[1]

Ok, I just had the IDENTICAL issue as yourself. (I cloned a project and tried to run tests on my local machine, but got the same FileNotFoundError:)

But I managed to solve it.

  1. First thing you need to have is Brownie itself (Obviously).

  2. Second thing is installed OpenZeppelin packages inside Brownie. Here is a link on how to set that up: @OpenZeppelin for Brownie

But in short, you just need this command:

brownie pm install OpenZeppelin/[email protected]

MAKE SURE IT'S THE VERSION OF @OpenZeppelin YOU NEED !!

3.Final step is to go into your project's build/contracts directory and delete ALL smartContract.json files and then do brownie compile anew.

After that you can run test etc, it should work.


IN DEPT EXPLANATION:


The reason we were getting that error was because Brownie uses smartCotnract.json build files to run the tests, and to locate all of its own dependencies/packages. Those .json files also contain paths to all of it (including @OpenZeppelin package), and are generated during compile phase only if they don't already exist or the code had been edited in a specific contract. (That is why you need to delete them if you want for brownie compile to generate new ones)

Therefor if I compile it on my local machine and push those smartContract.json files to git, and you happen to clone all of it and run the compile/tests. It is highly unlikely it will work, as name-path on my local machine will differ. (Username is practically 100% bound to be different)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sky