Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache not storing certain OpenZepplin dependencies causing initialization error #152

Closed
davoice-321 opened this issue Aug 23, 2024 · 3 comments

Comments

@davoice-321
Copy link

Environment information

  • ape and plugin versions:
$ ape --version
# ...copy and paste result of above command here..
0.8.12.

$ ape plugins list
# ...copy and paste result of above command here...

Installed Plugins
alchemy 0.8.0
ens 0.8.0
etherscan 0.8.2
foundry 0.8.4
hardhat 0.8.1
infura 0.8.0
solidity 0.8.3
template 0.8.0
tokens 0.8.0
vyper 0.8.4

  • Python Version: 3.11.8
  • OS: macOS/linux/win
    Description: Debian GNU/Linux trixie/sid
    Release: n/a
    Codename: trixie

What went wrong?

Ape is having trouble importing/finding multiple versions of OpenZepplin.

imports in solidity file separate versions of OZ based on version number, like so:

import {SafeMath} from "@openzeppelin-3.4.2/contracts/math/SafeMath.sol";

other versions of OZ are also present:
import "@openzeppelin-4.3.0/contracts/access/Ownable.sol";
import "@openzeppelin-4.3.0/contracts/security/ReentrancyGuard.sol";

This is in a situation where certain contract dependency files need to use lower solidity versions and using
pragma solidity >=0.6.0 <0.9.0 does not work in the OZ 3.4.2 SafeMath file (required for older .sol files in deployment) due to unchecked error.

different versions of OZ are in the ape.config file:
dependencies:

  • name: openzeppelin-3.4.2
    github: OpenZeppelin/openzeppelin-contracts
    version: 3.4.2
  • name: openzeppelin-4.5.0
    github: OpenZeppelin/openzeppelin-contracts
    version: 4.5.0
  • name: openzeppelin-4.3.0
    github: OpenZeppelin/openzeppelin-contracts
    version: 4.3.0

however, when loading VS Code instance, env slows down due to package not being found in cache and this error appears
Error: Dependency openzepplin-3.4.2 is declared on config file, but we could not find it inside [directory]. Try installing your dependencies ..

however, running ape compile sometimes shows the dependency is present
Compiling using Solidity compiler '0.6.10+commit.00c0fcaf'.
Input:
contracts/.cache/openzeppelin-3.4.2/3.4.2

  Other times the dependency is skipped. 

Screen shot of packages folder is included. Multiple OZ versions are present.

When commenting out that version of OZ (3.4.2) from the ape.config file, and running ape compile -f
this error appears:
Source "@openzeppelin-3.4.2/contracts/math/SafeMath.sol" not found: File not found.
import {SafeMath} from "@openzeppelin-3.4.2/contracts/math/SafeMath.sol";

Please include information like:

  • what command you ran
  • the code that caused the failure (see this link for help with formatting code)
  • full output of the error you received

How can it be fixed?

Resolving contracts/.cache file listing versus packages

Fill this in if you have ideas on how the bug could be fixed.
Screenshot 2024-08-23 at 12 54 13 PM

@antazoey
Copy link
Member

What VSCode integration are you using? That error is most likely not coming from us.

@antazoey
Copy link
Member

The problem is the NomicFoundation integration is out dated.
The repo to raise the bug with is here: https://github.com/NomicFoundation/hardhat-vscode
I can possibly guide them into what to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants