简体   繁体   English

尝试在 Docker 中运行 Brownie Dapp

[英]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:我试图在 docker 容器中运行我的 brownie dapp,但我总是有同样的错误并且似乎无法修复它:

FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/username/.brownie/packages/OpenZeppelin/openzeppelin-> > contracts@4.4.2/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:我将包含所有合约的 OpenZepplin 文件夹克隆到我项目的工作文件夹中,然后像这样重新映射它:依赖项:

  - OpenZeppelin/openzeppelin-contracts@4.4.2
compiler:
solc:
remappings:
      - "OpenZeppelin/openzeppelin-contracts@4.4.2/ = ./OpenZeppelin/openzeppelin-contracts@4.4.2/"

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/openzeppelin-contracts@4.4.2/contracts folder.但它仍然给出相同的错误,当我编译合同时,它显然仍在使用C:/Users/username/.brownie/packages/OpenZeppelin/openzeppelin-contracts@4.4.2/contracts文件夹。 I know this because I tried to compile the contracts with a remapping to a non-existing folder:我知道这一点是因为我试图通过重新映射到一个不存在的文件夹来编译合同:

remappings:
      - "OpenZeppelin/openzeppelin-contracts@4.4.2/ = ./nothing/"

and it still compiled perfectly.它仍然可以完美编译。

Just wondering if anybody could help me with this, and thank you in advance!只是想知道是否有人可以帮助我,在此先感谢您!

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:) (我克隆了一个项目并尝试在我的本地机器上运行测试,但得到了相同的 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.第二件事是在 Brownie 中安装 OpenZeppelin 包。 Here is a link on how to set that up: @OpenZeppelin for Brownie这是有关如何设置它的链接: @OpenZeppelin for Brownie

But in short, you just need this command:但简而言之,你只需要这个命令:

brownie pm install OpenZeppelin/openzeppelin-contracts@4.4.2

MAKE SURE IT'S THE VERSION OF @OpenZeppelin YOU NEED !!确保它是您需要的@OpenZeppelin 版本!!

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. 3.最后一步是将 go 进入项目的 build/contracts 目录并删除所有smartContract.json文件,然后重新brownie compile

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.我们收到该错误的原因是因为 Brownie 使用 smartCotnract.json 构建文件来运行测试,并找到它自己的所有依赖项/包。 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.那些.json 文件还包含所有文件的路径(包括@OpenZeppelin 包),并且仅当它们尚不存在或代码已在特定合约中被编辑时才会在编译阶段生成。 (That is why you need to delete them if you want for brownie compile to generate new ones) (这就是为什么如果你想让brownie compile生成新的,你需要删除它们)

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.因此,如果我在我的本地机器上编译它并将那些 smartContract.json 文件推送到 git,你碰巧克隆了所有它并运行编译/测试。 It is highly unlikely it will work, as name-path on my local machine will differ.它不太可能会起作用,因为我本地机器上的名称路径会有所不同。 (Username is practically 100% bound to be different) (用户名几乎 100% 不同)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试运行“brownie run.\scripts\deploy.py --network rinkeby”,但出现 ValueError - Trying to run "brownie run .\scripts\deploy.py --network rinkeby" but getting a ValueError 尝试运行 docker 服务器 - Trying to run a docker server 尝试在Docker中运行Cloudera Image - Trying to run Cloudera Image in Docker Docker:尝试在Docker中运行Docker时没有此类文件或目录 - Docker: No such file or directory when trying to run docker inside docker 尝试在不安装 MS Visual C++ 的情况下安装 Brownie - Trying to pipx install Brownie without installing MS Visual C++ 尝试从 chainlink 导入时 brownie-config 重新映射错误 - brownie-config remappings error when trying to import from chainlink 如何通过 typescript 中的巧克力蛋糕运行 python 脚本? - How can I run a python script through brownie from a typescript? 尝试在 Docker 中运行 Python 脚本时出现“ImportError: cannot import name...” - “ImportError: cannot import name…” when trying to run Python script in Docker 尝试在 docker 上运行一个容器但是无法访问我们创建的应用程序的网站 - Trying to run a container on docker but can not access the website of the application we created 尝试在 Docker 容器中运行 Selenium-pytest 时出现 KeyError - KeyError while trying to run Selenium-pytest in Docker Container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM