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 11.21.0 breaks firebase deploy functions compatibility with pnpm #5448

Closed
YannicEl opened this issue Jan 21, 2023 · 7 comments · Fixed by #5467
Closed

Version 11.21.0 breaks firebase deploy functions compatibility with pnpm #5448

YannicEl opened this issue Jan 21, 2023 · 7 comments · Fixed by #5467

Comments

@YannicEl
Copy link

YannicEl commented Jan 21, 2023

[REQUIRED] Environment info

firebase-tools: 11.21.0

Platform: Windows 11

Node: 18.13.0

[REQUIRED] Test case

https://github.com/YannicEl/firebase_tools_pnpm_bug

[REQUIRED] Steps to reproduce

  1. Run cd .\functions\
  2. Run pnpm install
  3. Replace <project_id> in ./functions/package.json with a valid project id that you have premission to deploy
  4. Run pnpm run deploy this will deploy the function in ./functions/src to the specified firebase project

[REQUIRED] Expected behavior

One callable function named handler ist deployed to the firebase project.

[REQUIRED] Actual behavior

The deploy fails with
In the console:

The system cannot find the path specified.

In the firebase-debug.log:

[debug] [2023-01-21T08:28:14.281Z] Error: spawn C:\Users\bamio\Desktop\firebase_tools_bug\node_modules\.pnpm\[email protected][email protected]\node_modules\.bin\firebase-functions ENOENT
    at notFoundError (C:\Users\bamio\Desktop\firebase_tools_bug\node_modules\.pnpm\[email protected]\node_modules\cross-spawn\lib\enoent.js:6:26)
    at verifyENOENT (C:\Users\bamio\Desktop\firebase_tools_bug\node_modules\.pnpm\[email protected]\node_modules\cross-spawn\lib\enoent.js:40:16)
    at cp.emit (C:\Users\bamio\Desktop\firebase_tools_bug\node_modules\.pnpm\[email protected]\node_modules\cross-spawn\lib\enoent.js:27:25)
    at ChildProcess._handle.onexit (node:internal/child_process:291:12)

When downgrading firebase-tools to the previous version 11.20.0 this works just fine. You can test this in the same repsoirtoy by running pnpm install [email protected] in ./functions

This might have somthing to do with #5391 but I am not entirly sure.

@YannicEl YannicEl added the bug label Jan 21, 2023
@evelant
Copy link

evelant commented Jan 21, 2023

This also affects the emulators. If you use pnpm and try to start the emulators on 11.21.0 you get

....path_to_project..../node_modules/.pnpm/[email protected][email protected]/node_modules/.bin/firebase-functions ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

Error: An unexpected error has occurred.

Perhaps a test case needs to be added to check if all 3 major package managers (npm, pnpm, yarn) work correctly before releases go out?

@laurentpayot
Copy link

Confirmed. Cannot run emulators anymore with firebase-tools v11.21.0 and pnpm v7.25.1. I’m getting the same unexpected error as @evelant.

@tofsjonas
Copy link

tofsjonas commented Jan 25, 2023

Similar problem here, on MacBook M1 macOs Ventura, node 18.13.0, pnpm 7.26, using emulator
Error in console:

Error: An unexpected error has occurred.

In firebase.log:

[debug] [2023-01-25T21:34:24.652Z] Building nodejs source
[debug] [2023-01-25T21:34:24.653Z] Could not find functions.yaml. Must use http discovery
[debug] [2023-01-25T21:34:24.656Z] Error: spawn /Users/jonas/Programmering/wow/bakhjarl/functions/node_modules/.pnpm/[email protected][email protected]/node_modules/.bin/firebase-functions ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

No problems with 11.20

@DibyodyutiMondal
Copy link

DibyodyutiMondal commented Jan 28, 2023

not just deploys, it also breaks emulator support. Current workaround for me is to run npm install inside the dist folder after output and before emulation or deploys.

If the list of deps is small, it's fine, but large deps become a problem.

Best alternative while we wait would be to:

  1. revert firebase-tools to version 11.20.0,
  2. use a script to symlink the workspace-level node_modules to dist/node_modules of the workspace.

this way we don't have to spend any time for installing, no matter the size

I use the following script for symlinking, (because I don't know how to symlink in linux directly)
Usage: node symlink.mjs node_modules dist/node_modules

symlink.mjs

import { rm, symlink } from "fs/promises";
import * as path from "path";
import { argv } from "process";

const cwd = process.cwd();

const target = path.join(cwd, argv[2]);
const dest = path.join(cwd, argv[3]);

await rm(dest, { force: true, recursive: true });

await symlink(target, dest);

taeold added a commit that referenced this issue Jan 30, 2023
Due to the way pnpm resolves packages with peer dependencies, location of the firebase functions sdk package isn't where the CLI expects it to be.

We make the logic for finding the binary associated Firebase Functions SDK more robust by checking list of possible paths where it might exist. We also add integration test for pnpm in the functions discovery test.

Fixes #5448
taeold added a commit that referenced this issue Jan 31, 2023
Due to the way pnpm resolves packages with peer dependencies, location of the firebase functions sdk package isn't where the CLI expects it to be.

We make the logic for finding the binary associated Firebase Functions SDK more robust by checking list of possible paths where it might exist. We also add integration test for pnpm in the functions discovery test.

Fixes #5448
@evelant
Copy link

evelant commented Jan 31, 2023

@taeold Is there going to be a release for this? I'm blocked by it at the moment and can't roll back to an earlier version due to #4952

@taeold
Copy link
Contributor

taeold commented Feb 1, 2023

@evelant Released today at v11.22.0!

@ChromeQ
Copy link

ChromeQ commented Feb 1, 2023

@taeold Success! 🎉 I can successfully run the emulator and deploy WITHOUT having to install deps inside the functions dir on v11.22.0.

Thank you so much for persevering and getting it fixed! 🙏

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

Successfully merging a pull request may close this issue.

8 participants