我正在尝试在Docker容器中运行我的布朗尼Dapp,但是我总是有相同的错误,并且似乎无法修复它:
FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/username/.brownie/packages/OpenZeppelin/openzeppelin-> > [email protected]/contracts/access/Ownable.sol'
我将所有合同用所有合同克隆到项目的工作文件夹,然后重新重新拍摄。像这样:
依赖项:
- OpenZeppelin/[email protected]
compiler:
solc:
remappings:
- "OpenZeppelin/[email protected]/ = ./OpenZeppelin/[email protected]/"
但是它仍然给出相同的错误,当我编译合同时,显然仍在使用 c:/users/username/.brownie/packages/openzeppelin/
remappings:
- "OpenZeppelin/[email protected]/ = ./nothing/"
它仍然完美地编译了合同。
只是想知道是否有人可以帮助我,并事先感谢您!
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!
发布评论
评论(1)
好的,我只是遇到了自己的问题。 (我克隆了一个项目,并试图在本地机器上运行测试,但是得到了相同的FilenotFoundError :)
但是我设法解决了它。
您需要拥有的第一件事是布朗尼本身(显然)。
第二件事是在布朗尼内部安装的OpenZeppelin包装。
这是有关如何设置的链接:
但简而言之,您只需要此命令:
确保它是@openzeppelin的版本!
3.最终步骤是进入项目的构建/合同目录并删除所有
smartContract.json
文件,然后进行Brownie Compile
重新。之后,您可以运行测试等,它应该起作用。
在Dept说明中:
我们遇到该错误的原因是因为Brownie使用SmartCotnract.json构建文件来运行测试,并找到其所有自己的依赖关系/软件包。这些.json文件还包含所有内容的路径(包括@openzeppelin软件包),并且仅在不存在或在特定合同中编辑代码时才能在编译阶段生成。 (这就是为什么如果您需要
Brownie Compile
来生成新的,则需要删除它们),如果我在本地计算机上编译并将这些smartContract.json文件推到git,然后您碰巧克隆所有这些并运行编译/测试。由于我本地机器上的名称会有所不同,因此它极不可能起作用。 (用户名实际上100%势必会不同)
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.
First thing you need to have is Brownie itself (Obviously).
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:
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 dobrownie 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)