Repository navigation
Description
[REQUIRED] Environment info
firebase-tools:
firebase-tools: 12.1.0
"firebase-admin": "^11.8.0",
"firebase-functions": "^4.3.1"
"firebase-functions-test": "^3.1.0"
**Platform: Windows wsl (Ubuntu)
Node: v18.16.0
Python: v3.10.6
openjdk: v"11.0.19"
[REQUIRED] Test case
i have followed the exact steps in
https://firebase.google.com/docs/functions/get-started?gen=2nd&hl=ko#about_this_tutorial
[REQUIRED] Expected behavior
No error should have occured
[REQUIRED] Actual behavior
When I run firebase emulators:start
i emulators: Starting emulators: functions, firestore
⚠ functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, database, hosting, pubsub, storage
i firestore: Firestore Emulator logging to firestore-debug.log
✔ firestore: Firestore Emulator UI websocket is running on
9150.
i ui: Emulator UI logging to ui-debug.log
i functions: Watching "/mnt/c/Users/sunwu/Downloads/Tryagain/pythontry/functions" for Cloud Functions...
✔ functions: Using node@18 from host.
⬢ functions: Failed to load function definition from source: FirebaseError: User code failed to load. Cannot determine
backend specification
┌─────────────────────────────────────────────────────────────┐
│ ✔ All emulators ready! It is now safe to connect your app. │
│ i View Emulator UI at http://127.0.0.1:4000/
│
└─────────────────────────────────────────────────────────────┘
┌───────────┬────────────────┬─────────────────────────────────┐
│ Emulator │ Host:Port │ View in Emulator UI
│
├───────────┼────────────────┼─────────────────────────────────┤
│ Functions │ 127.0.0.1:5001 │ http://127.0.0.1:4000/functions │
├───────────┼────────────────┼─────────────────────────────────┤
│ Firestore │ 127.0.0.1:8080 │ http://127.0.0.1:4000/firestore │
└───────────┴────────────────┴─────────────────────────────────┘
Emulator Hub running at 127.0.0.1:4400
Other reserved ports: 4500, 9150
Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files.
When I run firebase emulators:start --debug
firebase emulators:start --debug
[2023-05-24T00:10:55.555Z] > 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"]
[2023-05-24T00:10:55.556Z] > authorizing via signed-in user ([email protected])
[2023-05-24T00:10:55.604Z] openjdk version "11.0.19" 2023-04-18
OpenJDK Runtime Environment (build 11.0.19+7-post-Ubuntu-0ubuntu122.04.1)
[2023-05-24T00:10:55.605Z] OpenJDK 64-Bit Server VM (build 11.0.19+7-post-Ubuntu-0ubuntu122.04.1, mixed mode, sharing)
[2023-05-24T00:10:55.608Z] Parsed Java major version: 11
i emulators: Starting emulators: functions, firestore {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: functions, firestore"}}
[2023-05-24T00:10:55.614Z] assigned listening specs for emulators {"user":{"hub":[{"address":"127.0.0.1","family":"IPv4","port":4400}],"ui":[{"address":"127.0.0.1","family":"IPv4","port":4000}],"logging":[{"address":"127.0.0.1","family":"IPv4","port":4500}],"firestore":[{"address":"127.0.0.1","family":"IPv4","port":8080}],"firestore.websocket":[{"address":"127.0.0.1","family":"IPv4","port":9150}]},"metadata":{"message":"assigned listening specs for emulators"}}
[2023-05-24T00:10:55.620Z] [hub] writing locator at /tmp/hub-nodejs-a4db9.json
[2023-05-24T00:10:55.625Z] late-assigned ports for functions and eventarc emulators {"user":{"hub":[{"address":"127.0.0.1","family":"IPv4","port":4400}],"ui":[{"address":"127.0.0.1","family":"IPv4","port":4000}],"logging":[{"address":"127.0.0.1","family":"IPv4","port":4500}],"firestore":[{"address":"127.0.0.1","family":"IPv4","port":8080}],"firestore.websocket":[{"address":"127.0.0.1","family":"IPv4","port":9150}],"functions":[{"address":"127.0.0.1","family":"IPv4","port":5001}],"eventarc":[{"address":"127.0.0.1","family":"IPv4","port":9299}]},"metadata":{"message":"late-assigned ports for functions and eventarc emulators"}}
⚠ functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, database, hosting, pubsub, storage {"metadata":{"emulator":{"name":"functions"},"message":"The following emulators are not running, calls to these services from the Functions emulator will affect production: \u001b[1mauth, database, hosting, pubsub, storage\u001b[22m"}}
[2023-05-24T00:10:55.627Z] defaultcredentials: writing to file /home/sunwu/.config/firebase/sunwu5678_gmail_com_application_default_credentials.json
[2023-05-24T00:10:55.628Z] Setting GAC to /home/sunwu/.config/firebase/sunwu5678_gmail_com_application_default_credentials.json {"metadata":{"emulator":{"name":"functions"},"message":"Setting GAC to /home/sunwu/.config/firebase/sunwu5678_gmail_com_application_default_credentials.json"}}
[2023-05-24T00:10:55.631Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/nodejs-a4db9/adminSdkConfig [none]
[2023-05-24T00:10:56.042Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/nodejs-a4db9/adminSdkConfig 200
[2023-05-24T00:10:56.042Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/nodejs-a4db9/adminSdkConfig {"projectId":"nodejs-a4db9","storageBucket":"nodejs-a4db9.appspot.com"}
[2023-05-24T00:10:56.077Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: auto_download"}}
[2023-05-24T00:10:56.077Z] Ignoring unsupported arg: single_project_mode_error {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: single_project_mode_error"}}
[2023-05-24T00:10:56.077Z] Starting Firestore Emulator with command {"binary":"java","args":["-Djava.net.preferIPv4Stack=true","-Dgoogle.cloud_firestore.debug_log_level=FINE","-Duser.language=en","-jar","/home/sunwu/.cache/firebase/emulators/cloud-firestore-emulator-v1.17.4.jar","--host","127.0.0.1","--port",8080,"--websocket_port",9150,"--project_id","nodejs-a4db9","--rules","/mnt/c/Users/sunwu/Downloads/Tryagain/pythontry/firestore.rules","--single_project_mode",true,"--functions_emulator","127.0.0.1:5001"],"optionalArgs":["port","webchannel_port","host","rules","websocket_port","functions_emulator","seed_from_export","project_id","single_project_mode"],"joinArgs":false} {"metadata":{"emulator":{"name":"firestore"},"message":"Starting Firestore Emulator with command {"binary":"java","args":["-Djava.net.preferIPv4Stack=true","-Dgoogle.cloud_firestore.debug_log_level=FINE","-Duser.language=en","-jar","/home/sunwu/.cache/firebase/emulators/cloud-firestore-emulator-v1.17.4.jar","--host","127.0.0.1","--port",8080,"--websocket_port",9150,"--project_id","nodejs-a4db9","--rules","/mnt/c/Users/sunwu/Downloads/Tryagain/pythontry/firestore.rules","--single_project_mode",true,"--functions_emulator","127.0.0.1:5001"],"optionalArgs":["port","webchannel_port","host","rules","websocket_port","functions_emulator","seed_from_export","project_id","single_project_mode"],"joinArgs":false}"}}
i firestore: Firestore Emulator logging to firestore-debug.log {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator logging to \u001b[1mfirestore-debug.log\u001b[22m"}}
[2023-05-24T00:10:57.195Z] May 24, 2023 9:10:57 AM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketServer start
INFO: Started WebSocket server on ws://127.0.0.1:9150
{"metadata":{"emulator":{"name":"firestore"},"message":"May 24, 2023 9:10:57 AM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketServer start\nINFO: Started WebSocket server on ws://127.0.0.1:9150\n"}}
[2023-05-24T00:10:57.291Z] API endpoint: http://127.0.0.1:8080
{"metadata":{"emulator":{"name":"firestore"},"message":"API endpoint: http://127.0.0.1:8080\n"}}
[2023-05-24T00:10:57.292Z] If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:
export FIRESTORE_EMULATOR_HOST=127.0.0.1:8080
Dev App Server is now running.
{"metadata":{"emulator":{"name":"firestore"},"message":"If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:\n\n export FIRESTORE_EMULATOR_HOST=127.0.0.1:8080\n\nDev App Server is now running.\n\n"}}
✔ firestore: Firestore Emulator UI websocket is running on 9150. {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator UI websocket is running on 9150."}}
[2023-05-24T00:10:57.362Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: auto_download"}}
[2023-05-24T00:10:57.363Z] Ignoring unsupported arg: port {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: port"}}
[2023-05-24T00:10:57.364Z] Starting Emulator UI with command {"binary":"node","args":["/home/sunwu/.cache/firebase/emulators/ui-v1.11.6/server/server.js"],"optionalArgs":[],"joinArgs":false} {"metadata":{"emulator":{"name":"ui"},"message":"Starting Emulator UI with command {"binary":"node","args":["/home/sunwu/.cache/firebase/emulators/ui-v1.11.6/server/server.js"],"optionalArgs":[],"joinArgs":false}"}}
i ui: Emulator UI logging to ui-debug.log {"metadata":{"emulator":{"name":"ui"},"message":"Emulator UI logging to \u001b[1mui-debug.log\u001b[22m"}}
[2023-05-24T00:10:57.486Z] Web / API server started at 127.0.0.1:4000
{"metadata":{"emulator":{"name":"ui"},"message":"Web / API server started at 127.0.0.1:4000\n"}}
i functions: Watching "/mnt/c/Users/sunwu/Downloads/Tryagain/pythontry/functions" for Cloud Functions... {"metadata":{"emulator":{"name":"functions"},"message":"Watching "/mnt/c/Users/sunwu/Downloads/Tryagain/pythontry/functions" for Cloud Functions..."}}
[2023-05-24T00:10:57.657Z] Validating nodejs source
[2023-05-24T00:10:58.198Z] > [functions] package.json contents: {
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "18"
},
"main": "index.js",
"dependencies": {
"firebase-admin": "^11.8.0",
"firebase-functions": "^4.3.1"
},
"devDependencies": {
"firebase-functions-test": "^3.1.0"
},
"private": true
}
[2023-05-24T00:10:58.203Z] Building nodejs source
[2023-05-24T00:10:58.204Z] Failed to find version of module node: reached end of search path /mnt/c/Users/sunwu/Downloads/Tryagain/pythontry/functions/node_modules
✔ functions: Using node@18 from host.
[2023-05-24T00:10:58.215Z] Could not find functions.yaml. Must use http discovery
[2023-05-24T00:10:58.240Z] Found firebase-functions binary at '/mnt/c/Users/sunwu/Downloads/Tryagain/pythontry/functions/node_modules/.bin/firebase-functions'
[2023-05-24T00:11:02.712Z] Serving at port 8528
[2023-05-24T00:11:16.857Z] shutdown requested via /__/quitquitquit
⬢ functions: Failed to load function definition from source: FirebaseError: User code failed to load. Cannot determine backend specification {"metadata":{"emulator":{"name":"functions"},"message":"Failed to load function definition from source: FirebaseError: User code failed to load. Cannot determine backend specification"}}
┌─────────────────────────────────────────────────────────────┐
│ ✔ All emulators ready! It is now safe to connect your app. │
│ i View Emulator UI at http://127.0.0.1:4000/ │
└─────────────────────────────────────────────────────────────┘
┌───────────┬────────────────┬─────────────────────────────────┐
│ Emulator │ Host:Port │ View in Emulator UI │
├───────────┼────────────────┼─────────────────────────────────┤
│ Functions │ 127.0.0.1:5001 │ http://127.0.0.1:4000/functions │
├───────────┼────────────────┼─────────────────────────────────┤
│ Firestore │ 127.0.0.1:8080 │ http://127.0.0.1:4000/firestore │
└───────────┴────────────────┴─────────────────────────────────┘
Emulator Hub running at 127.0.0.1:4400
Other reserved ports: 4500, 9150
Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files




Activity
saitogo555 commentedon May 24, 2023
I had the same error in almost the same environment as you.
I don't know the exact cause, but I have found that the problem is caused by firebase-tools.
I downgraded the firebase-tools version to 11.29.1 and it works fine.
Also, version 12.2.0 has now been released, so maybe the latest version will work.
blidd-google commentedon May 25, 2023
Hi @sunwupark, thanks for reporting this error. From the details you provided, it's difficult to diagnose the underlying issue causing your functions code to not load. Could you provide your source code, or a simple example that I could use to reproduce your issue? Thanks.
thandal commentedon May 26, 2023
I had the same problem, downgrading also worked for me -- thanks @saitogo555 !
hamzahoda commentedon May 28, 2023
Got the same error
Error: User code failed to load. Cannot determine backend specification.
Turns out that when I initialized a new project using Firebase init the default nodejs version it uses is 18.
Just needed to change my version in the package.json file to the current one installed on my system. For me, it was 16.
"engines": { "node": "16" },
qeema commentedon May 30, 2023
We had same problem when we use wsl and mnt folder(local windows).
But, using only wsl(folder is on wsl ubuntu not "/mnt" directory) was worked.
google-oss-bot commentedon Jun 8, 2023
Hey @sunwupark. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
google-oss-bot commentedon Jun 13, 2023
Since there haven't been any recent updates here, I am going to close this issue.
@sunwupark if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.
80 remaining items
agustinFeijoo commentedon Nov 11, 2024
Same issue
dsl101 commentedon Nov 27, 2024
Is the
FUNCTIONS_DISCOVERY_TIMEOUTenvironment variable not working for some? I've had this kind of thing in package.json scripts for ages, and it's solved it completely:rubenheymans commentedon Dec 1, 2024
how can you verify this variable is set correctly?
dsl101 commentedon Dec 2, 2024
Well, for me, the error goes away :)
dsl101 commentedon Dec 4, 2024
You 'found' something that was posted back in June and I commented on last week. I swear people just aren't reading this thread...
HunderlineK commentedon Dec 29, 2024
This is also happening, locally and also on IDX - it's such a non-descriptive error
saurabhchalke commentedon Dec 30, 2024
Thanks for the suggestion! @dsl101
It works for my by adding the following env variable while running the function deploy command:
FUNCTIONS_DISCOVERY_TIMEOUT=60shahbaz-khan-hub commentedon Jan 31, 2025
make sure you have installed firebase tools locally in the project to check run
npm list firebse-toolsif you see something like another directory not your project directory it means you have not installed firebase tools locally in the projectcarloslfu commentedon Apr 1, 2025
For people trying to deploy Python functions, you need to add a
requirements.txtin the source dir. Same for Node, you need apackage.jsonin the source dir.This is the code responsible for that:
firebase-tools/src/deploy/functions/runtimes/python/index.ts
Line 29 in caaf1af
Saddamdev0 commentedon Apr 23, 2025
Hey when I faced this issue I looked there were node modules unnecessarily installed in my functions folder so I just deleted them, also make sure you dont have any firebase-functions installed in functions, take a look at package.json if there is any firebase-functions then within the same directory run npm uninstall firebase-functions.
madmacc commentedon Apr 23, 2025
For me this does not occur if I stay on the window (Keep it in focus) while deploying functions.
If I start the deploy then leave the window I will get this error and have to run it a second time for it to work.
It is also affected by my local backup software running.
I believe may be to do with resources on my local computer. My machine is kind of old.
nfairfield commentedon Apr 30, 2025
My 2c: I always have to run firebase command-lines twice. The first time, I get this error. The second time (and subsequent), it works just fine (even if its from two different powershell instances). I mention this because I fear that some of the solutions above... are really just people trying different things multiple times, and eventually it works.
It seems to be some sort of credential/caching issue, but I've never been able to track it down.
dsl101 commentedon May 1, 2025
Have you tried this solution and it doesn't work? What values for the timeout have you experimented with? Providing more data would be really helpful...
depikaguptaa commentedon Jul 2, 2025
Downgrading to previous version worked for me!