-
Notifications
You must be signed in to change notification settings - Fork 976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"functions: Failed to load functions source code. Ensure that you have the latest SDK by...." #609
Comments
Try running |
Unfortunately, I don't have a package.json configured for that.
Can you point me to one? |
This is what mine looks like after a fresh |
I've managed to work around this error by downgrading Longer storyI first stumbled upon this error in my CI runner, bc I was installing the latest version of But then my local environment stopped working. I could still deploy, but couldn't serve functions. Tried uninstalling Finally, I decided to roll everything back to the versions that were working before and froze the version used in my CI script (instead of using the latest) and now both environments work consistently. I've seen different variations of this issue with different possible solutions dating a few months back. Maybe it's a regression? Some obscure underlying issue? BTW: I'm running macOS High Sierra 10.13.2 locally and the node:latest Docker image for my CI runner on GitLab, if that helps. PS: In my experience, |
@rafasoares : thank you, can confirm that downgrading to 3.16.0 fixed the error!
I'm using macOS High Sierra 10.13.2 too, but I'm using node v6.11.5 installed through |
@The-Alchemist glad I could help. I've tried both with the latest node installed via brew (9.x) and 6.11.5 installed through nvm. It was working before with the latest node (with the GCP node version warning, though). |
Hi everyone, the latest firebase-tools (3.17.1) also requires the latest firebase-functions SDK, so the better way to solve the problems would be to run "npm i --save firebase-functions@latest" inside the functions folder prior to deploying or serving, as the error message suggests. |
@laurenzlong did you read my comment above? It was the first thing I tried. After that, I was able to And I've tried all manner of cleanup strategies I could come up with. I even deleted my working copy and pulled everything from Git from scratch. |
@rafasoares Apologies, I missed that part. I'll look into it now. |
Awesome! Thanks! |
v3.17.2 has now been released and should have fixed the problem, please let me know if it doesn't. Thanks for reporting! |
Just tried v3.17.2, worked for me! |
It didn't work for me. I managed to make it work on a blank project, but couldn't make my current project work. So I went digging. What are the differences between the two? I was able to pinpoint the issue. It breaks when I add this bit of code: const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase); // <-- Specifically, this line If I remove the initialization bit, I can serve the functions. However, I can't use Firestore. |
Update: If I replace the {
databaseURL: 'https://[PROJECT_NAME].firebaseio.com',
storageBucket: '[PROJECT_NAME].appspot.com',
apiKey: '[API KEY]',
authDomain: '[PROJECT_NAME].firebaseapp.com',
projectId: '[PROJECT_NAME]',
credential: admin.credential.applicationDefault()
} That JSON was the output of I haven't tried deploying with this code, though. |
@rafasoares I downgraded the google-cloud/functions-emulator dependency, that's the difference. Try "npm uninstall -g firebase-tools & npm i -g firebase-tools". Depending on the npm version you have, sometimes it doesn't downgrade dependencies unless you do an uninstall first. |
@rafasoares Seems like I got semver versioning wrong, I think I fixed it in #618, can you try using that branch? npm install -g https://github.com/firebase/firebase-tools.git#laurenzlong-patch-1 |
I had same problem as @rafasoares, and I tried By |
I'm sorry, I have been playing around with Yarn and NPM trying to get them to download the right version, I've probably messed up my environment haha. But yeah, https://github.com/firebase/firebase-tools.git#laurenzlong-patch-1 still gives me the error, even though |
@mono0926 @rafasoares How about this? Thanks for your patience and help! |
This still gives me the error, unfortunately :( |
what about |
I already tried that. |
Apparently https://github.com/firebase/firebase-tools.git#ll-fixemu fixes it for me. $ yarn global remove firebase-tools
yarn global v1.3.2
[1/2] Removing module firebase-tools...
[2/2] Regenerating lockfile and installing missing dependencies...
success Uninstalled packages.
✨ Done in 3.91s.
$ yarn global add https://github.com/firebase/firebase-tools.git\#ll-fixemu
yarn global v1.3.2
[1/4] 🔍 Resolving packages...
warning https://github.com/firebase/firebase-tools.git#ll-fixemu > universal-analytics > node-uuid@1.4.8: Use uuid module instead
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
[4/4] 📃 Building fresh packages...
success Installed "firebase-tools@3.17.2" with binaries:
- firebase
✨ Done in 11.73s.
$ firebase --version
3.17.2
$ firebase serve --only functions
=== Serving from '/Users/[USERNAME]/dev/projects/[PROJECT NAME]'...
i functions: Preparing to emulate functions.
✔ functions: createUrl: http://localhost:5000/[PROJECT NAME]/us-central1/createUrl
✔ functions: getUrl: http://localhost:5000[PROJECT NAME]us-central1/getUrl I'm currently using node v6.11.5. @mono0926 maybe that has got something to do with it? |
@mono0926 We never supported custom config values inside of the emulator, you need to run "firebase functions:config:get > .runtimeconfig.json" inside your functions folder so the variables get stored in .runtimeconfig.json and can be accessed by the emulator. @marcus7777 I think this is a separate issue, captured in #442 I'm closing this issue now since the originally reported error is fixed in v.3.17.3 |
It's amazing how quickly this was dealt with. Awesome work @laurenzlong. 👏 |
I see. I forgot to write this information. {
"environment": {
"project_id": "development"
}
} I was able to access |
@mono0926 Can you open a new issue for this? And also include what version of firebase-functions you are using? |
Okay, I opened an issue 👍 : #629 |
just update to 3.17.4 still get:
and has tryed #442 but no luck. |
@marcus7777 the problem you are facing is unrelated to this is issue. Try removing firebase-tools and reinstalling it. If it doesn't work, open a new issue. |
I also had success deleting the local state of the emulator: $HOME/.config/configstore/@google-cloud/functions-emulator/.functions.json and similar files. |
Hello, I'm also having this problem with firebase-tools@3.17.5. As noted by @rafasoares the problem appears if I add this line:
This is the error I'm getting:
Also when I downgrade to
@laurenzlong Maybe there is something I'm missing? |
@BernalCarlos As the error message suggests, please make sure you are on the latest firebase-functions version. Run the following in your functions directory: `npm i --save firebase-functions@latest' Afterwards, your functions/package.json should have firebase-functions 0.8.1 |
@laurenzlong I already have the latest version of firebase-functions. This is my package.json:
In the yarn.lock I also have this:
But the problem is still present. |
Thanks for sharing your package.json, can you tell me what your project directory structure is? We do not yet support mono repos, so there needs to be a functions/node_modules/firebase-functions folder. |
Sure @laurenzlong this my project directory structure, it quite big because of the node_modules folder: |
With firebase-tools@3.17.5 (i.e firebase CLI) problem appears again, it does not related directly to functions, but if you roll back to 3.17.4 emulation will work. |
@Rulsky with irebase-tools@3.17.4, it fails with a different error for a very simple function:
Error:
Also I noticed that a log file is created when the firebase CLI is running, but such file gets deleted immediately after. Is there a way to keep this log file from being deleted? |
@BernalCarlos have you put service Admin key into your project's |
You actually don't need to set GOOGLE_APPLICATION_CREDENTIALS if you're not using Firebase auth or other Google APIs. So @BernalCarlos I think your issue is the same as #691, which I've made a fix for and linked to in that issue. |
I have a clean project just with the function that the CLI creates and is not working when I include
|
@Jhony0311 you're probably also affected by #691 |
I can use It stays loading after executing "npm run serve", i functions: Preparing to emulate functions.
This is my code: 'use strict';
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.getSomeData = functions.https.onRequest((req, res) => {
admin.firestore().doc('feedback/d8pGxmML5ZKLYEy5jyhm').get()
.then(doc => res.send(doc.data()))
.catch(err => res.status(500).send(err));
}); Any suggestions? |
Hi, problem with node 10
Use older version. Version 8, for example.
…On 4 Jul 2018, 01:46 +0200, Nicolas Sturm ***@***.***>, wrote:
I can use firebase deploy --only functions but no firebase serve --only functions.
It stays loading after executing "npm run serve",
i functions: Preparing to emulate functions.
Warning: You're using Node.js v10.5.0 but Google Cloud Functions only supports v6.11.5.
⚠ functions: Failed to emulate getSomeData
i functions: No HTTPS functions found. Use firebase functions:shell if you would like to emulate other types of functions.
firebase version: 3.19.3
This is my code:
'use strict';
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.getSomeData = functions.https.onRequest((req, res) => {
admin.firestore().doc('feedback/d8pGxmML5ZKLYEy5jyhm').get()
.then(doc => res.send(doc.data()))
.catch(err => res.status(500).send(err));
});
Any suggestions?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
In case it helps others, I was trying to use To solve this, I had to copy the package.json Dialogflow used rather than the one |
I have the exact same issue. I think we're just going to bail on using environmental variables in our various deployment stages and just use a JSON config file. I would love to see a fix, running npm does absolutely nothing to fix this. |
In my case, I fixed the bug by running |
I have updated all firebase-tools, firebase-admin, firebase-functions to the latest one
However, I still see this error when I want to run firebase functions shell
|
@Randyanto hello, I can't tell you clear answer but I may give you some clues. I got the same error too. In my case, I couldn't work |
Version info
Steps to reproduce
Actual behavior
It's very strange, because in other projects,
firebase serve --only functions
freezes, and I tried a bunch of other samples. It doesn't work in any of them.It even doesn't work for functions I already have deployed.
The text was updated successfully, but these errors were encountered: