NomicFoundation / hardhat

Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
https://hardhat.org
Other
7.24k stars 1.39k forks source link

Unexpected "npx hardhat compile" error on start > "Carl Pilcher" #2235

Closed geode-main closed 2 years ago

geode-main commented 2 years ago

When we are using hardhat for our contracts we faced with an infinite loop on terminal when we tried to update every package with

npm install

weird texts in sample output can be seen here:

undefined
undefined
undefined
                                   !             H|H|H|H|H           H__________________________________             H|§|§|§|H           H|* * * * * *|---------------------|             H|§|∞|§|H           H| * * * * * |---------------------|             H|§|§|§|H           H|* * * * * *|---------------------|             H|H|H|H|H           H| * * * * * |---------------------|             H|H|H|H|H           H|---------------------------------|          ===============        H|---------------------------------|            /| _   _ |          H|---------------------------------|            (| O   O |)          H|---------------------------------|            /|   U   |          H-----------------------------------             |  =/  |           H              _..._/            H              _|I/|_            H      _______/| H |/_______    H     /           / /          H    |          | | /         |  H    |          ||o||          |  H    |    |     ||o||     |    |  H    |    |     ||o||     |    |  H   Carl Pilcher  
te sting tes ting testing  tes ti n g t esting te ҉ st i ng testing
testing te st ing t estin g t esting  testing testin g  tes ting 
testing  testing testing te sting testing  ҉ testing testing
...

Notably there is a name in the output: "Carl Pilcher"

Issue resisted with different computers and node versions also on different terminals.

Afterwards, we tried to create a new hardhat example project and tested it with: ( choose Create an advanced sample project)

npm install --save-dev hardhat 
npx hardhat
npx hardhat compile

Issue resisted.

hardhat version : v2.8.2 node version: v16.13.1 npm -v : 8.1.2

Please reproduce the issue and let us know how to fix it.

geode-main commented 2 years ago

Seems like the issue is about https://github.com/Marak/colors.js/issues/289

Which is dependent to:
https://github.com/Marak/faker.js

geode-main commented 2 years ago

Please downgrade any "faker.js" dependency to faker@5.5.3 to fix the problem.

jummy123 commented 2 years ago

Another workaround is adding the following to package.json

  "resolutions": {
    "**/colors": "1.4.0"
  }
cgewecke commented 2 years ago

I think this is actually coming from eth-gas-reporter (which depends on colors - an npm package that broke over the weekend as noted in comments above).

The latest release of hardhat-gas-reporter (1.0.7) patches it and pins colors to 1.4.0.

AFAIK hardhat uses chalk & isn't directly affected by this bug.

geode-main commented 2 years ago

Yes, the issue is about gas reporter but still, hardhat needs to fix this and not be dependent to such failure on such a small task.

cgewecke commented 2 years ago

@geode-main For context this bug was introduced intentionally by the package maintainer and designed to cause problems for anyone who imported it at the file level. It broke hundreds of major projects across the node ecosystem and resulted in interventions by npm and github to roll back the package version (edit: not sure about npm actually) and freeze the maintainer's OSS account. It's an unusual event.

The main issue thread in the repo is here: https://github.com/Marak/colors.js/issues/285

lpsm-dev commented 2 years ago

Today the most of our docker node build pipelines had this problem. To solve this I added the force-resolutions setup in package.json

Context

Broken docker build step of some node projects in GitLab CI pipelines.

Steps

  1. Add preinstall command in scripts section of package.json.
"preinstall": "([ ! -f package-lock.json ] && npm install --package-lock-only --ignore-scripts --no-audit); npx npm-force-resolutions",
  1. Add resolutions to colors lib:
 "resolutions": {
    "**/colors": "1.4.0"
  }

Outputs

Before

image

After

image

github-actions[bot] commented 2 years ago

This issue was marked as stale because it didn't have any activity in the last 30 days. If you think it's still relevant, please leave a comment indicating so. Otherwise, it will be closed in 7 days.

github-actions[bot] commented 2 years ago

This issue was closed because it has been stalled for 7 days with no activity.