NomicFoundation / hardhat-vscode

Solidity and Hardhat support for Visual Studio Code

Home Page:https://hardhat.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Source "@openzeppelin/..." not found: File not found. solidity(6275)

AuroraLantean opened this issue · comments

I am using Solidity v0.7.3 by Nomic Foundation in two Foundry repositories, and both have the same file structure, foundry.toml, installed forge dependencies, and remappings.txt

The difference between those two repos are file numbers in src and test folders.
In the smaller repo, I have one Solidity file importing dependencies from openzeppelin and aave. And the plugin in VS Code shows no problem.

in the bigger repo, after adding lots of files into src and test folders, the plugin showed no problem yesterday.
BUT today when I opened up VS Code, this plugin started to show this error:
Source "forge-std/console.sol" not found: File not found. Searched the following locations: "".solidity(6275)
Source "@openzeppelin/contracts/..." not found: File not found. Searched the following locations: "".solidity(6275)

Another difference is in the cache/solidity-files-cache.json
The bigger repo has "sources": "abc", BUT the smaller repo has "sources": "src"
Here is the first few lines from the bigger repo's solidity-files-cache.json:

{
  "_format": "ethers-rs-sol-cache-3",
  "paths": {
    "artifacts": "out",
    "build_infos": "out/build-info",
    "sources": "abc",
    "tests": "test",
    "scripts": "script",
    "libraries": [
      "lib"
    ]
  },

forge build and forge test ... all work fine in both repos. So the problem is not in file structure, foundry.toml, installed forge dependencies, or remappings.txt. I think somehow the plugin could not see remappings.txt... please help. Thanks