webhintio / hint

πŸ’‘ A hinting engine for the web
https://webhint.io/
Apache License 2.0
3.62k stars 679 forks source link

[Bug] "A valid configuration file can't be found" loop on installation #3134

Open mahomedalid opened 5 years ago

mahomedalid commented 5 years ago

πŸ› Bug report

When installing webhint from WSL using npx hint https://www.mysite.com/ the process can't create a default configuration file and remains in a loop. I know it could be something from my environment but a detailed error why file could not be created (missing utility, permissions, etc.) could be useful.

Description

  1. $ npx hint https://www.mysite.com/
  2. A valid configuration file can't be found. Do you want to use the default configuration? To know more about the default configuration see: https://webhint.io/docs/user-guide/#default-configuration (Y/n), Y
  3. A valid configuration file can't be found. Do you want to use the default configuration? To know more about the default configuration see: https://webhint.io/docs/user-guide/#default-configuration (Y/n), Y
  4. A valid configuration file can't be found. Do you want to use the default configuration? To know more about the default configuration see: https://webhint.io/docs/user-guide/#default-configuration (Y/n), Y
  5. ... loop ...

Environment

Debug output

raw output ``` mahome@CSEMAHO /mnt/c/Users/mapach/source/repos $ npx hint https://snowballv2.azurewebsites.net/ info looking for cached prebuild @ /home/mahome/.npm/_prebuilds/47fbee-iltorb-v2.4.3-node-v59-linux-x64.tar.gz http request GET https://github.com/MayhemYDG/iltorb/releases/download/v2.4.3/iltorb-v2.4.3-node-v59-linux-x64.tar.gz http 404 https://github.com/MayhemYDG/iltorb/releases/download/v2.4.3/iltorb-v2.4.3-node-v59-linux-x64.tar.gz WARN install No prebuilt binaries found (target=9.10.0 runtime=node arch=x64 libc= platform=linux) gyp ERR! build error gyp ERR! stack Error: not found: make gyp ERR! stack at getNotFoundError (/usr/lib/node_modules/npm/node_modules/which/which.js:13:12) gyp ERR! stack at F (/usr/lib/node_modules/npm/node_modules/which/which.js:68:19) gyp ERR! stack at E (/usr/lib/node_modules/npm/node_modules/which/which.js:80:29) gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/which.js:89:16 gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/index.js:42:5 gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/mode.js:8:5 gyp ERR! stack at FSReqWrap.oncomplete (fs.js:170:21) gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/mode.js:8:5 gyp ERR! stack at FSReqWrap.oncomplete (fs.js:170:21) gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /home/mahome/.npm/_npx/174/lib/node_modules/hint/node_modules/iltorb gyp ERR! node -v v9.10.0 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Couldn't find any valid configuration β”‚ β”‚ β”‚ β”‚ Running hint with the default configuration. β”‚ β”‚ β”‚ β”‚ Learn more about how to create your own configuration at: β”‚ β”‚ β”‚ β”‚ https://webhint.io/docs/user-guide/ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ A valid configuration file can't be found. Do you want to use the default configuration? To know more about the default configuration see: https://webhint.io/docs/user-guide/#default-configuration (Y/n)Y β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Couldn't find any valid configuration β”‚ β”‚ β”‚ β”‚ Running hint with the default configuration. β”‚ β”‚ β”‚ β”‚ Learn more about how to create your own configuration at: β”‚ β”‚ β”‚ β”‚ https://webhint.io/docs/user-guide/ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ A valid configuration file can't be found. Do you want to use the default configuration? To know more about the default configuration see: https://webhint.io/docs/user-guide/#default-configuration (Y/n)Y β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Couldn't find any valid configuration β”‚ β”‚ β”‚ β”‚ Running hint with the default configuration. β”‚ β”‚ β”‚ β”‚ Learn more about how to create your own configuration at: β”‚ β”‚ β”‚ β”‚ https://webhint.io/docs/user-guide/ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ A valid configuration file can't be found. Do you want to use the default configuration? To know more about the default configuration see: https://webhint.io/docs/user-guide/#default-configuration (Y/n) Y ```
mahomedalid commented 5 years ago
mahomedalid commented 5 years ago

Default configuration returns:

{"extends":["web-recommended"]}

But, the analyzer throws an exception trying to parse it:

AnalyzerError: Invalid configuration. ResourceError: Resource web-recommended not found

sarvaje commented 5 years ago

@mahomedalid can you run npx hint https://snowballv2.azurewebsites.net/ --debug and paste the output?

sarvaje commented 5 years ago

For now, I can't reproduce your loop error, but it doesn't work for me neither in wsl (ubuntu 18.04) because it can't find a chromium installation.

hint:cli:analyze Failed to analyze: undefined +4s
  hint:cli:analyze Error: No installation found                                                                          hint:cli:analyze     at Object.exports.getInstallationPath (/home/sarvaje/.npm/_npx/1891/lib/node_modules/hint/node_modules/@hint/utils/dist/src/chromium-finder.js:235:15)
  hint:cli:analyze     at PuppeteerConnector.toPuppeteerOptions (/home/sarvaje/.npm/_npx/1891/lib/node_modules/hint/node_modules/@hint/connector-puppeteer/dist/src/connector.js:44:21)
  hint:cli:analyze     at new PuppeteerConnector (/home/sarvaje/.npm/_npx/1891/lib/node_modules/hint/node_modules/@hint/connector-puppeteer/dist/src/connector.js:31:30)
  hint:cli:analyze     at new Engine (/home/sarvaje/.npm/_npx/1891/lib/node_modules/hint/dist/src/lib/engine.js:33:26)   hint:cli:analyze     at Analyzer.analyze (/home/sarvaje/.npm/_npx/1891/lib/node_modules/hint/dist/src/lib/analyzer.js:140:27)
  hint:cli:analyze     at exports.default (/home/sarvaje/.npm/_npx/1891/lib/node_modules/hint/dist/src/lib/cli/analyze.js:319:23)
  hint:cli:analyze     at process._tickCallback (internal/process/next_tick.js:68:7)                                     hint:cli:analyze     at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)                                hint:cli:analyze     at findNodeScript.then.existing (/home/sarvaje/.nvm/versions/node/v10.16.3/lib/node_modules/npm/node_modules/libnpx/index.js:268:14) +0ms                                                                                hint:cli:analyze Total runtime: 299ms +4ms      
molant commented 5 years ago

so likely something with permissions on WSL.

This is the most probable cause. I think we should detect if we are running via npx and if so no prompt if we don't find a configuration and go directly with the default.

@sarvaje thoughts?

sarvaje commented 5 years ago

I thought that the default behavior was if we don't find a configuration file, run directly the default configuration.

The problem here I think is that for some reason, he is having problem with the web-recommended configuration.

sarvaje commented 5 years ago

I have double check, and we only ask to use the default configuration if there is any problem loading the configuration, which makes this issue more weird, because the default configuration should be valid... :s

molant commented 5 years ago

@mahomedalid can you please run npx hint -v to see what version are you running?

mahomedalid commented 5 years ago

$ npx hint -v v5.3.3

mahomedalid commented 5 years ago

In case the trace is useful:

Trace
    at Console.originalConsole.(anonymous function) [as trace] (/mnt/c/Users/mapach/source/repos/Snowball/node_modules/diagnostic-channel-publishers/dist/src/console.pub.js:42:39)
    at Object.create [as createAnalyzer] (/mnt/c/Users/mapach/source/repos/Snowball/node_modules/hint/dist/src/lib/analyzer.js:63:14)
    at getAnalyzer (/mnt/c/Users/mapach/source/repos/Snowball/node_modules/hint/dist/src/lib/cli/analyze.js:217:23)
    at exports.default (/mnt/c/Users/mapach/source/repos/Snowball/node_modules/hint/dist/src/lib/cli/analyze.js:268:25)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:118:7)
    at Function.Module.runMain (module.js:692:11)
    at startup (bootstrap_node.js:194:16)
    at bootstrap_node.js:666:3

   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚                                                                                             β”‚
   β”‚   AnalyzerError: Invalid configuration. ResourceError: Resource web-recommended not found   β”‚
   β”‚                                                                                             β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
sarvaje commented 5 years ago

@mahomedalid can you run npx hint https://snowballv2.azurewebsites.net/ --debug and copy the output here?

mahomedalid commented 5 years ago
 $ npx hint https://snowballv2.azurewebsites.net/ --debug
  hint:mnt:c:Users:mapach:source:repos:Snowball:node_modules:@hint:utils:dist:src:app-insights Application Insight disabled +0ms
  hint:mnt:c:Users:mapach:source:repos:Snowball:node_modules:@hint:utils:dist:src:network:as-uri Adding valid target: https://snowballv2.azurewebsites.net/ +0ms
  hint:config Loading package.json config file: /mnt/c/Users/mapach/source/repos/Snowball/package.json +0ms

   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚                                                               β”‚
   β”‚             Couldn't find any valid configuration             β”‚
   β”‚                                                               β”‚
   β”‚         Running hint with the default configuration.          β”‚
   β”‚                                                               β”‚
   β”‚   Learn more about how to create your own configuration at:   β”‚
   β”‚                                                               β”‚
   β”‚              https://webhint.io/docs/user-guide/              β”‚
   β”‚                                                               β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

  hint:cli:analyze Using language option configured in the OS: en-US +0ms

  hint:config:config-validator Validating configuration +0ms
  hint:config Composing configuration from extends +33ms

A valid configuration file can't be found. Do you want to use the default configuration? To know more about the default configuration see: https://webhint.io/docs/user-guide/#default-configuration (Y/n)
mahomedalid commented 5 years ago

I think I may have a hint of what is the problem. iltorb could not be installed (no prebuilt binaries for this specific ubuntu WSL version), hence loadResource is failing.

I'm installing gcc to see if that could solve the problem. I know this is could be considered very low priority because at the end puppeter will be a major challenge and I can just run this on powershell.

Details:

Info looking for cached prebuild @ /home/mahome/.npm/_prebuilds/47fbee-iltorb-v2.4.3-node-v59-linux-x64.tar.gz
http request GET https://github.com/MayhemYDG/iltorb/releases/download/v2.4.3/iltorb-v2.4.3-node-v59-linux-x64.tar.gz
http 404 https://github.com/MayhemYDG/iltorb/releases/download/v2.4.3/iltorb-v2.4.3-node-v59-linux-x64.tar.gz
WARN install No prebuilt binaries found (target=9.10.0 runtime=node arch=x64 libc= platform=linux)
gyp ERR! build error 
gyp ERR! stack Error: not found: make
gyp ERR! stack     at getNotFoundError (/usr/lib/node_modules/npm/node_modules/which/which.js:13:12)
gyp ERR! stack     at F (/usr/lib/node_modules/npm/node_modules/which/which.js:68:19)
gyp ERR! stack     at E (/usr/lib/node_modules/npm/node_modules/which/which.js:80:29)
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/which.js:89:16
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/index.js:42:5
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/mode.js:8:5
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:170:21)
gyp ERR! System Linux 4.4.0-18362-Microsoft
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /mnt/c/Users/mapach/source/repos/Snowball/node_modules/iltorb
gyp ERR! node -v v9.10.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
sarvaje commented 5 years ago

yep, that can be the problem, I usually install nodejs and build-essential

mahomedalid commented 5 years ago

Correct, after install g++ and gcc, works .. well, it fails to try to find puppeter.

$ npx hint https://snowballv2.azurewebsites.net/ --debug
$ sudo apt-get install g++ gcc
hint:engine Initializing hint engine +0ms
  hint:cli:analyze Failed to analyze: undefined +5s
  hint:cli:analyze Error: No installation found
  hint:cli:analyze     at Object.exports.getInstallationPath (/mnt/c/Users/mapach/source/repos/Snowball/node_modules/@hint/utils/dist/src/chromium-finder.js:235:15)
  hint:cli:analyze     at PuppeteerConnector.toPuppeteerOptions (/mnt/c/Users/mapach/source/repos/Snowball/node_modules/@hint/connector-puppeteer/dist/src/connector.js:44:21)
  hint:cli:analyze     at new PuppeteerConnector (/mnt/c/Users/mapach/source/repos/Snowball/node_modules/@hint/connector-puppeteer/dist/src/connector.js:31:30)
  hint:cli:analyze     at new Engine (/mnt/c/Users/mapach/source/repos/Snowball/node_modules/hint/dist/src/lib/engine.js:33:26)
  hint:cli:analyze     at Analyzer.analyze (/mnt/c/Users/mapach/source/repos/Snowball/node_modules/hint/dist/src/lib/analyzer.js:140:27)
  hint:cli:analyze     at exports.default (/mnt/c/Users/mapach/source/repos/Snowball/node_modules/hint/dist/src/lib/cli/analyze.js:319:23)
  hint:cli:analyze     at <anonymous>
  hint:cli:analyze     at process._tickCallback (internal/process/next_tick.js:118:7)
  hint:cli:analyze     at Function.Module.runMain (module.js:692:11)
  hint:cli:analyze     at findNodeScript.then.existing (/usr/lib/node_modules/npm/node_modules/libnpx/index.js:268:14) +1ms
  hint:cli:analyze Total runtime: 1197ms +4ms
sarvaje commented 5 years ago

well, it fails to try to find puppeter

Yep, that is expected in wsl1 hehehe.

molant commented 5 years ago

Need to merge #3140 sooner rather than later to move away from binaries πŸ˜“ Also I just saw that you are running node 9.10.0 which is no longer maintained (and not supported by webhint). Can you try updating to a more recent version see if you have the same issues?

chryw commented 5 years ago

Same issue here.

npx hint https://webhint.io result is blank and it exits:

➜ ~ πŸ˜ΈπŸ‘‰ npx hint https://webhint.io        
info looking for cached prebuild @ /Users/cherwan/.npm/_prebuilds/db4ff3-iltorb-v2.4.3-node-v64-darwin-x64.tar.gz
info found cached prebuild 
info unpacking @ /Users/cherwan/.npm/_prebuilds/db4ff3-iltorb-v2.4.3-node-v64-darwin-x64.tar.gz
info unpack resolved to /Users/cherwan/.npm/_npx/26032/lib/node_modules/hint/node_modules/iltorb/build/bindings/iltorb.node
info unpack required /Users/cherwan/.npm/_npx/26032/lib/node_modules/hint/node_modules/iltorb/build/bindings/iltorb.node successfully
info install Successfully installed iltorb binary!
βœ– 
➜ ~ πŸ˜ΈπŸ‘‰ 

sudo npx hint https://webhint.io result is the loop that @mahomedalid mentioned

   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚                                                               β”‚
   β”‚             Couldn't find any valid configuration             β”‚
   β”‚                                                               β”‚
   β”‚         Running hint with the default configuration.          β”‚
   β”‚                                                               β”‚
   β”‚   Learn more about how to create your own configuration at:   β”‚
   β”‚                                                               β”‚
   β”‚              https://webhint.io/docs/user-guide/              β”‚
   β”‚                                                               β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
A valid configuration file can't be found. Do you want to use the default configuration? To know more about the default configuration see: https://webhint.io/docs/user-guide/#default-configuration (Y/n)y
hxlnt commented 5 years ago

@chryw's Mac "red X" result repro'd by @codepo8 as well: MicrosoftTeams-image (4)

If a fix might be a bit in the future, should we update the npx instructions in the docs? Want to be sure a new user's first experience is a good one.

molant commented 4 years ago

With the latest release we've improved the error reporting and moved away from binaries. We still download canvas but it's an optional dependency so even if there is an issue with the package the process should continue.

I believe there's still an issue with WSL but at least it should tell you that the browser is not found.

Can you please give it a try?

tristan957 commented 3 years ago

This is still happening as of version 6.1.3. I don't use WSL. I use Fedora 33.

khitermedachraf commented 2 years ago

I have the same Infinity loop on windows 10. but just in a local repository for example running this command: npx hint ./index.html it works with : npx hint https://webhint.io

jaredatandi commented 2 years ago

I have the same issue on Ubuntu 22.04.