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

Validation blocked due HH18: Corrupted lockfile, on Windows VSCode when using WSL hardhat project

3esmit opened this issue · comments

Hardhat version: 2.16.1
NPM 9.7.2
Node Version: v18.16.1
OS: Windows 11 for VSCode, but using WSL 2 with Ubuntu 22.04 for project

I had tried doing what the error message says (delete node_modules and package-lock.json, and reinstall project) but it didn't helped.
npx hardhat compile works fine, this issue is just on the vscode extension. Its not related to the project, its related to WSL project vs Windows VScode.
When I run npm install, its on a WSL console, but VSCode is running on the native Windows OS, therefore the platform specific modules are installed for Linux, but when hardhat-vscode tries to run them, they conflict because its being ran in Windows.

If you are also having this problem, there is an workaround:

  1. Run VSCode from WSL (click on the right bottom blue button with >< symbols, click "Connect with WSL")
  2. Install hardhat-vscode extension in WSL VSCode
  3. Open folder passing the linux path e.g. /mnt/c/Users/<your-user>/<your-project-folder>/ on WSL VSCode

If this is not going to be fixed, at least the HH18 error message should include this information: "If you are running on WSL, you should use also VSCode on WSL"

Agreed. We should enhance the warning message to give guidance to WSL users.

The platform specific elements of Hardhat, and our use of hardhat during validation of hardhat projcts, force the requirement of running the extension in WSL.

We should update the docs to reflect this as well, and give a more detailed explanation of the constraint.