From 523ace7e9a543156fe0d2b78528f2d30d24b4121 Mon Sep 17 00:00:00 2001 From: Jacob Lindahl Date: Thu, 22 Aug 2024 01:30:34 +0900 Subject: [PATCH] chore(docs): adds instructions for `Cannot read properties of undefined (reading 'compilerPath')` error resolution (#2642) Encountered an issue when setting up new development environment: when running `zk init`, it would fail with the following error: ```text Creating Typechain artifacts in directory typechain for target ethers-v5 Successfully generated Typechain artifacts! $ ts-node scripts/compile-yul.ts compile-precompiles Using zksolc from https://github.com/matter-labs/era-compiler-solidity/releases/download/prerelease-a167aa3-code4rena/zksolc-macosx-arm64-v1.5.0 Yarn project directory: /Users/jacob/Projects/zksync-era/contracts/system-contracts Error: Cannot read properties of undefined (reading 'compilerPath') error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. error Command failed. Exit code: 1 ``` Thus, this PR updates the "Troubleshooting" section of `docs/guides/launch.md` with the resolution instructions. --- docs/guides/launch.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/guides/launch.md b/docs/guides/launch.md index 35588debd3ae..10c0b10f5d84 100644 --- a/docs/guides/launch.md +++ b/docs/guides/launch.md @@ -320,3 +320,24 @@ to: ``` "@matterlabs/hardhat-zksync-solc": "^0.3.15", ``` + +### Error: Cannot read properties of undefined (reading 'compilerPath') + +**Problem**. `zk init` fails with an error similar to the following: + +```text +Yarn project directory: /Users//Projects/zksync-era/contracts/system-contracts +Error: Cannot read properties of undefined (reading 'compilerPath') +error Command failed with exit code 1. +``` + +**Description**. The compiler downloader +[could not verify](https://github.com/NomicFoundation/hardhat/blob/0d850d021f3ab33b59b1ea2ae70d1e659e579e40/packages/hardhat-core/src/internal/solidity/compiler/downloader.ts#L336-L383) +that the Solidity compiler it downloaded actually works. + +**Solution**. Delete the cached `*.does.not.work` file to run the check again: + +```sh +# NOTE: Compiler version, commit hash may differ. +rm $HOME/Library/Caches/hardhat-nodejs/compilers-v2/macosx-amd64/solc-macosx-amd64-v0.8.20+commit.a1b79de6.does.not.work +```