Skip to content

hardhat 3 does't work with yarn v4 in pnp mode #7563

@adrian-gierakowski

Description

@adrian-gierakowski

Version of Hardhat

3.0.7

What happened?

error when trying to run a node due to invalid check for "non-local installation of Hardhat"

> DEBUG="hardhat:*" yarn hardhat node --fork https://rpc.sepolia.linea.build --chain-id 59141 --fork-block-number 19180872
  hardhat:cli:telemetry:telemetry-permissions Telemetry is allowed in the current environment: true +0ms
  hardhat:cli:telemetry:telemetry-permissions Looking for telemetry config file at /home/my-user/.local/share/hardhat-nodejs/telemetry-config.json +3ms
  hardhat:cli:telemetry:telemetry-permissions No telemetry config file found, assuming telemetry is enabled +0ms
  hardhat:cli:telemetry:sentry:reporter Initializing Reporter instance +0ms
  hardhat:core:sentry:init Setting up global unhandled error handlers +0ms
  hardhat:core:cli:main Hardhat CLI started +0ms
  hardhat:core:cli:main Parsed builtin global options +0ms
  hardhat:core:cli:main Determined that Hardhat is not installed locally/linked +3ms
  hardhat:core:cli:main   resolved package.json: undefined +0ms
  hardhat:core:cli:main   current package.json: /home/my-user/.yarn/berry/cache/hardhat-npm-3.0.7-da627f3526-10c0.zip/node_modules/hardhat/package.json +0ms
Error HHE22: Trying to use a non-local installation of Hardhat, which is not supported.

Please install Hardhat locally using pnpm, npm or yarn, and try again.

For more info go to https://hardhat.org/HHE22 or run Hardhat with --show-stack-traces

MAIN issues seems to be not being able to locate package.json: hardhat:core:cli:main resolved package.json: undefined +0ms

Minimal reproduction steps

  • Install Yarn v4
    npm install -g corepack
  • Verify Yarn version (4.10.3 used in repro)
    yarn -v 
  • Init Hardhat 3
    yarn dlx hardhat --init
  • Run Hardhat tests
    yarn hardhat test --show-stack-traces
    • Result
      Error HHE22: Trying to use a non-local installation of Hardhat, which is not supported.
      
      Please install Hardhat locally using pnpm, npm or yarn, and try again.
      
      HardhatError: HHE22: Trying to use a non-local installation of Hardhat, which is not supported.
      
      Please install Hardhat locally using pnpm, npm or yarn, and try again.
          at main (/root/.yarn/berry/cache/hardhat-npm-3.0.7-da627f3526-10c0.zip/node_modules/hardhat/src/internal/cli/main.ts:107:13)
          at async file:///root/.yarn/berry/cache/hardhat-npm-3.0.7-da627f3526-10c0.zip/node_modules/hardhat/dist/src/cli.js:21:1

Search terms

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    To-do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions