Firebase-tools: firebase emulators:start --only functions,hosting not working

Created on 16 Jan 2020  路  10Comments  路  Source: firebase/firebase-tools

[REQUIRED] Environment info


firebase-tools:
7.12.1

Platform:
win 10

[REQUIRED] Test case

firebase emulators:start --only functions,hosting

[REQUIRED] Steps to reproduce

execute firebase emulators:start --only functions,hosting

[REQUIRED] Expected behavior


both emulators should start

[REQUIRED] Actual behavior

i  emulators: Starting emulators:
!  Not starting the functions hosting emulator, make sure you have run firebase init.
+  All emulators started, it is now safe to connect.

it works if i run functions and hosting emulator seperately

Related SO question https://stackoverflow.com/questions/59774625/not-able-to-exclude-firestore-from-firebase-emulatorsstart/59774650

Attention emulator-suite bug

Most helpful comment

@JerryGoyal turns out that commas are special in PowerShell:
https://stackoverflow.com/questions/11990688/powershell-is-removing-comma-from-program-argument

So you need to add quotes:

# This WILL NOT work
firebase emulators:start --only functions,hosting

# This will work
firebase emulators:start --only "functions,hosting"

All 10 comments

Can you provide your firebase.json file? You need either:

  1. a hosting key set in the top level (easy, typical), or
  2. a emulators.hosting entry (which I'm not confident of the form of that off the top of my head)

Can you provide your firebase.json file? You need either:

  1. a hosting key set in the top level (easy, typical), or
  2. a emulators.hosting entry (which I'm not confident of the form of that off the top of my head)

but it works when i run them seperately.

{
  "hosting": {
    "public": "_site",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
    "rewrites": [
      {
        "source": "/bigben",
        "function": "bigben"
      },
      {
        "source": "**",
        "destination": "/index.html"
      }
    ],
    "cleanUrls": true
  },
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint",
      "npm --prefix \"$RESOURCE_DIR\" run build"
    ]
  },
  "emulators": {
    "functions": {
      "port": 5001
    },
    "hosting": {
      "port": 5000
    }
  }
}

Hmm so this warning is interesting:

!  Not starting the functions hosting emulator, make sure you have run firebase init.

That warning comes from this code in controller.ts:

  if (options.only) {
    const requested: string[] = options.only.split(",");
    const ignored = _.difference(requested, targets);
    for (const name of ignored) {
      utils.logWarning(
        `Not starting the ${clc.bold(name)} emulator, make sure you have run ${clc.bold(
          "firebase init"
        )}.`
      );
    }
  }

It's trying to start an emulator called functions hosting when it should see functions and hosting separately.

@JerryGoyal can you try running this command and showing the logs:

firebase --debug emulators:start --only functions,hosting

@samtstern

PS C:\Users\1gour\Github\app> firebase --debug emulators:start --only functions,hosting
[2020-01-26T14:06:42.995Z] ----------------------------------------------------------------------
[2020-01-26T14:06:42.998Z] Command:       C:\Program Files\nodejs\node.exe C:\Users\1gour\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js --debug emulators:start --only functions hosting
[2020-01-26T14:06:42.998Z] CLI Version:   7.12.1
[2020-01-26T14:06:42.999Z] Platform:      win32
[2020-01-26T14:06:42.999Z] Node Version:  v10.16.3
[2020-01-26T14:06:42.999Z] Time:          Sun Jan 26 2020 19:36:42 GMT+0530 (India Standard Time)
[2020-01-26T14:06:43.000Z] ----------------------------------------------------------------------
[2020-01-26T14:06:42.998Z] CLI Version:   7.12.1
[2020-01-26T14:06:42.999Z] Platform:      win32
[2020-01-26T14:06:42.999Z] Node Version:  v10.16.3
[2020-01-26T14:06:42.999Z] Time:          Sun Jan 26 2020 19:36:42 GMT+0530 (India Standard Time)
[2020-01-26T14:06:43.000Z] ----------------------------------------------------------------------
[2020-01-26T14:06:43.000Z]
[2020-01-26T14:06:43.000Z]
[2020-01-26T14:06:43.021Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2020-01-26T14:06:43.027Z] > authorizing via signed-in user
i  emulators: Starting emulators:
!  Not starting the functions hosting emulator, make sure you have run firebase init.
+  All emulators started, it is now safe to connect.

@JerryGoyal hmm what shell are you using on Windows? It seems to be messing up the command parsing:

PS C:\Users\1gour\Github\app> firebase --debug emulators:start --only functions,hosting
[2020-01-26T14:06:42.995Z] ----------------------------------------------------------------------
[2020-01-26T14:06:42.998Z] Command:       C:\Program Files\nodejs\node.exe C:\Users\1gour\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js --debug emulators:start --only functions hosting

You can see the first line says --only functions,hosting but the second line says --only functions hosting. Since we split the argument on commas it thinks you're trying to start the functions hosting emulator for some reason...

@samtstern I see, that shouldn't be happening.
I am using PowerShell 6.2.3 (https://aka.ms/pscore6-docs) in VSCode.
so, should I file the bug in PS repo?

@JerryGoyal maybe ... do you have another shell you can try to see if that's part of the issue?

@JerryGoyal turns out that commas are special in PowerShell:
https://stackoverflow.com/questions/11990688/powershell-is-removing-comma-from-program-argument

So you need to add quotes:

# This WILL NOT work
firebase emulators:start --only functions,hosting

# This will work
firebase emulators:start --only "functions,hosting"

@samtstern that was exactly the issue with commas. It worked when added the quotes around that. Thanks for the extra efforts to pinpoint the issue and resolution.

Was this page helpful?
0 / 5 - 0 ratings