Skip to content
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

Version 13.7.0 now requires manually adding "runtime" configuration in firebase.json #6965

Closed
vitoras opened this issue Apr 5, 2024 · 5 comments · Fixed by #6968
Closed

Comments

@vitoras
Copy link

vitoras commented Apr 5, 2024

[REQUIRED] Environment info

firebase-tools:
13.7.0

Platform:
macOS
Sonoma 14.4.1

[REQUIRED] Test case

Right after upgrading to firebase-tools v13.7.0, the emulators started showing the error Trying to construct a python runtime delegate for runtime nodejs20 on start. I'm testing a function on Python 3.12, and I noticed it works when I add "runtime": "python312" on firebase.json as per the documentation.

But this was never required before.

[REQUIRED] Steps to reproduce

  1. Create a blank function from scratch with firebase init, choosing "Functions" and "Emulators" as features and Python as language. Using an existing project or a new one is irrelevant, but everything else can be left as default in the rest of the process;
  2. Runing firebase emulators:start after firebase finished creating the function will give the aforementioned error message;
  3. You have to manually add the "runtime": "python312" on firebase.json;
  4. Run firebase emulators:start again and then it will load your function correctly.

Here are some evidences of the fail case without the runtime info on firebase.json, and the success case after I added it:

No runtime on firebase.json (out of the box)

Captura de Tela 2024-04-05 às 01 39 30

With runtime on firebase.json (manually added)

Captura de Tela 2024-04-05 às 01 41 25

[REQUIRED] Expected behavior

I noticed the runtime validation was just introduced in this line from this commit, but maybe it would be reasonable if the runtime config could be either automatically inferred from firebase init when we select the function language, or at least prompted to be selected by ourselves from the list of supported runtimes.

In any case, not everybody is expected to know right away that they have to manually add this information on firebase.json, let alone find a Stackoverflow answer for a newly created error message.

[REQUIRED] Actual behavior

Running firebase:emulators start --debug gives the following log at the end:

i  ui: Emulator UI logging to ui-debug.log {"metadata":{"emulator":{"name":"ui"},"message":"Emulator UI logging to \u001b[1mui-debug.log\u001b[22m"}}
[2024-04-05T04:27:26.600Z] 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"}}
[2024-04-05T04:27:26.600Z] Web / API server started at ::1:4000
 {"metadata":{"emulator":{"name":"ui"},"message":"Web / API server started at ::1:4000\n"}}
i  functions: Watching "/Users/xxxxx/test-function/functions" for Cloud Functions... {"metadata":{"emulator":{"name":"functions"},"message":"Watching \"/Users/xxxxx/test-function/functions\" for Cloud Functions..."}}
[2024-04-05T04:27:26.785Z] Customer code is not Node
⬢  functions: Failed to load function definition from source: FirebaseError: Internal error. Trying to construct a python runtime delegate for runtime nodejs20 {"metadata":{"emulator":{"name":"functions"},"message":"Failed to load function definition from source: FirebaseError: Internal error. Trying to construct a python runtime delegate for runtime nodejs20"}}
@vitoras vitoras changed the title Version 13.7.0 now requires manually adding "runtime" value in firebase.json Apr 5, 2024
@amfc
Copy link

amfc commented Apr 5, 2024

I think this also applies to nodejs:

I just just upgraded (npm i -g firebase-tools) and started receiving:

functions: Your requested "node" version "20" doesn't match your global version "18". Using node@18 from host.

even though I have node version 18 in package.json

by setting functions: { runtime: "nodejs18" } in firebase.json it stopped giving the warning.

@aalej
Copy link
Contributor

aalej commented Apr 5, 2024

Hey @vitoras, thanks for the thorough report as well as for sharing your observations, and thanks @amfc for the additional information. I was able to reproduce the issue. It looks like both Node.js and Python runtimes are affected here.

As a workaround for those who also encounter this issue, please specify the runtime in your firebase.json file. Here's references for setting the Node.js version and Python version. I’ll raise this to our engineering team so that we can determine what the appropriate action here would be. I’ll also mark this as reproducible.

@vitoras
Copy link
Author

vitoras commented Apr 5, 2024

I think this also applies to nodejs:

I just just upgraded (npm i -g firebase-tools) and started receiving:

functions: Your requested "node" version "20" doesn't match your global version "18". Using node@18 from host.

even though I have node version 18 in package.json

by setting functions: { runtime: "nodejs18" } in firebase.json it stopped giving the warning.

Yeah, this idea was raised in this issue, but maybe they overlooked that impact.

@inlined
Copy link
Member

inlined commented Apr 5, 2024

Today's release of the CLI fixes the issue.

@vitoras
Copy link
Author

vitoras commented Apr 6, 2024

Today's release of the CLI fixes the issue.

Thanks a lot, now the emulators are working as before!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment