firebase-tools: 7.2.0
Platform: debian over WSL1
firebase login fails when running under WSL.
firebase loginExpected to listen on local port.
$ firebase login --debug
[2019-07-25T03:53:52.524Z] ----------------------------------------------------------------------
[2019-07-25T03:53:52.532Z] Command: /usr/bin/node /usr/bin/firebase login --debug
[2019-07-25T03:53:52.532Z] CLI Version: 7.2.0
[2019-07-25T03:53:52.533Z] Platform: linux
[2019-07-25T03:53:52.535Z] Node Version: v12.7.0
[2019-07-25T03:53:53.767Z] Time: Thu Jul 25 2019 13:53:52 GMT+1000 (GMT+10:00)
[2019-07-25T03:53:53.768Z] ----------------------------------------------------------------------
? Allow Firebase to collect anonymous CLI usage and error reporting information? Yes
Visit this URL on any device to log in:
(omitted)
Waiting for authentication...
[2019-07-25T03:53:55.869Z] Error: spawn cmd.exe ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:77:11)
Error: An unexpected error has occurred.
firebase-tools attempts to spawn cmd.exe, which doesn't exist. If I were to guess, it thinks it's running under Windows.
Hi @shaneqld, sorry to hear that you're having trouble. Your guess seems accurate - it looks like the call to http.server in auth.js is failing because it thinks it is running on Windows.
For now, could you try to login by instead running firebase login --no-localhost ? This shouldn't be using http.server, so it should hopefully work in your environment.
Hi @joehan, running with or without --no-localhost flag on 7.2.1 results in the same issue:
$ firebase login --no-localhost --debug
[2019-07-30T03:09:56.252Z] ----------------------------------------------------------------------
[2019-07-30T03:09:56.256Z] Command: /usr/bin/node /usr/bin/firebase login --no-localhost --debug
[2019-07-30T03:09:56.256Z] CLI Version: 7.2.1
[2019-07-30T03:09:56.257Z] Platform: linux
[2019-07-30T03:09:56.257Z] Node Version: v12.7.0
[2019-07-30T03:09:57.598Z] Time: Tue Jul 30 2019 13:09:56 GMT+1000 (GMT+10:00)
[2019-07-30T03:09:57.599Z] ----------------------------------------------------------------------
? Allow Firebase to collect anonymous CLI usage and error reporting information? Yes
Visit this URL on any device to log in:
(omitted)
? Paste authorization code here: [2019-07-30T03:10:00.108Z] Error: spawn cmd.exe ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:77:11)
Error: An unexpected error has occurred.
Taking a quick look into this, it seems to be an issue in the open node package.
Taking a further look into this, it seems open package invokes cmd.exe which it expects is on the PATH environment variable. Adding /mnt/c/Windows/system32 to PATH resolves the problem.
@shaneqld thanks for investigating! Looks the same as this issue:
https://github.com/firebase/firebase-tools/issues/1442
Let's close this one and you can track the fix over there.
Try this if you face the same issue
PATH="$PATH:/mnt/c/Windows/System32" firebase login
If adding the path to cmd.exe still doesnt do the trick, uninstall firebase-tools and follow these steps
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally#manually-change-npms-default-directory
then reinstall firebase-tools without sudo
Most helpful comment
Try this if you face the same issue
PATH="$PATH:/mnt/c/Windows/System32" firebase login