Skip to content

Version 11.21.0 breaks firebase deploy functions compatibility with pnpm  #5448

Closed

Description

@YannicEl

[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.

Activity

  1. evelant commented on Jan 21, 2023

    @evelant

    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?

  2. self-assigned this
    on Jan 22, 2023
  3. laurentpayot commented on Jan 23, 2023

    @laurentpayot

    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.

  4. tofsjonas commented on Jan 25, 2023

    @tofsjonas

    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

  5. DibyodyutiMondal commented on Jan 28, 2023

    @DibyodyutiMondal

    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);
  6. evelant commented on Jan 31, 2023

    @evelant

    @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

  7. taeold commented on Feb 1, 2023

    @taeold
    Contributor

    @evelant Released today at v11.22.0!

  8. ChromeQ commented on Feb 1, 2023

    @ChromeQ

    @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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions