Open christopherdbull opened 8 months ago
I would just like to add that following this guide also leads to the same problem.
I'm on Mac too, Next 13.4.1 and was on firebase tools 12.4.4 until just updated to 12.7.0 to check if it would fix this issue - it did not. Up until yesterday evening my app had been deploying for months nicely to Firebase framework-aware hosting for Next JS. I made today a couple of small code changes - no new libs, no new config, nothing major like that. And suddenly firebase deploy fails in build step with similar symptoms: sharp & libvips.
Checked manually on my Mac to download the sharp-libvips outlined in the error message. Downloaded nicely.
i functions: updating Node.js 18 (2nd Gen) function firebase-frameworks-trailmapv2-staging:ssrtrailmapv2staging(europe-west1)...
.....
npm ERR! code 1
npm ERR! path /workspace/node_modules/sharp
npm ERR! command failed
npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
npm ERR! sharp: Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.14.5/libvips-8.14.5-linux-x64.tar.br
npm ERR! sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies
npm ERR! sharp: Installation error: read ECONNRESET
npm ERR! A complete log of this run can be found in: /www-data-home/.npm/_logs/2023-10-22T14_18_41_613Z-debug-0.log.
...Tried again to deploy this morning. The issue I reported above 15 hours ago is gone - luckily a temporary Cloud Build issue.
Can anyone solve it?
`Building a Cloud Function to run this application. This is needed due to: • non-static component /_not-found
npm ERR! code 2 npm ERR! path /Users//Desktop//.firebase/function-name/functions/node_modules/protobufjs npm ERR! command failed npm ERR! command /Users/**/.cache/firebase/runtime/shell -c -- node scripts/postinstall npm ERR! /bin/sh: --: invalid option npm ERR! Usage: /bin/sh [GNU long option] [option] ... npm ERR! /bin/sh [GNU long option] [option] script-file ... npm ERR! GNU long options: npm ERR! --debug npm ERR! --debugger npm ERR! --dump-po-strings npm ERR! --dump-strings npm ERR! --help npm ERR! --init-file npm ERR! --login npm ERR! --noediting npm ERR! --noprofile npm ERR! --norc npm ERR! --posix npm ERR! --protected npm ERR! --rcfile npm ERR! --restricted npm ERR! --verbose npm ERR! --version npm ERR! --wordexp npm ERR! Shell options: npm ERR! -irsD or -c command or -O shopt_option (invocation only) npm ERR! -abefhkmnptuvxBCHP or -o option
npm ERR! A complete log of this run can be found in: npm ERR! /Users/**/.npm/_logs/2023-10-24T11_44_03_007Z-debug-0.log
Error: An unexpected error has occurred.`
I am unable to deploy my production firebase functions due to the same error
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run build
> build
> npm run lint && tsc
/bin/sh: --: invalid option
Usage: /bin/sh [GNU long option] [option] ...
/bin/sh [GNU long option] [option] script-file ...
GNU long options:
--debug
--debugger
--dump-po-strings
--dump-strings
--help
--init-file
--login
--noediting
--noprofile
--norc
--posix
--protected
--rcfile
--restricted
--verbose
--version
--wordexp
Shell options:
-irsD or -c command or -O shopt_option (invocation only)
-abefhkmnptuvxBCHP or -o option
Error: functions predeploy error: Command terminated with non-zero exit code 2
error Command failed with exit code 1.
Same issue on fresh firebase init and deploy on Mac
Please let me know if there are any other logs or info I can send along to help debug - this is a pretty big issue for my company as we cannot deploy updates to our production firebase functions
Same issue also on MacOS Sonoma
Usage: /bin/sh [GNU long option] [option] ...
/bin/sh [GNU long option] [option] script-file ...
GNU long options:
--debug
--debugger
--dump-po-strings
--dump-strings
--help
--init-file
--login
--noediting
--noprofile
--norc
--posix
--protected
--rcfile
--restricted
--verbose
--version
--wordexp
Shell options:
-irsD or -c command or -O shopt_option (invocation only)
-abefhkmnptuvxBCHP or -o option
Error: functions predeploy error: Command terminated with non-zero exit code 2```
Also having the above issue. Clean install, new project, nothing untoward going on. Firebase Functions default code, typescript, firebase-cli@12.9.1
I am unable to deploy my production firebase functions due to the same error
i deploying functions Running command: npm --prefix "$RESOURCE_DIR" run build > build > npm run lint && tsc /bin/sh: --: invalid option Usage: /bin/sh [GNU long option] [option] ... /bin/sh [GNU long option] [option] script-file ... GNU long options: --debug --debugger --dump-po-strings --dump-strings --help --init-file --login --noediting --noprofile --norc --posix --protected --rcfile --restricted --verbose --version --wordexp Shell options: -irsD or -c command or -O shopt_option (invocation only) -abefhkmnptuvxBCHP or -o option Error: functions predeploy error: Command terminated with non-zero exit code 2 error Command failed with exit code 1.
I was able to deploy by downgrading my firebase tools npm -g install firebase-tools@12.0.0
This just happened to me on an M1 Mac, I removed my current version
npm -g uninstall firebase-tools
or
sudo rm -rf /usr/local/bin/firebase
// only if you have installed the CLI in a different way
and reinstalled the old firebase-tools@12.0.0 did the trick
I am unable to deploy my production firebase functions due to the same error
i deploying functions Running command: npm --prefix "$RESOURCE_DIR" run build > build > npm run lint && tsc /bin/sh: --: invalid option Usage: /bin/sh [GNU long option] [option] ... /bin/sh [GNU long option] [option] script-file ... GNU long options: --debug --debugger --dump-po-strings --dump-strings --help --init-file --login --noediting --noprofile --norc --posix --protected --rcfile --restricted --verbose --version --wordexp Shell options: -irsD or -c command or -O shopt_option (invocation only) -abefhkmnptuvxBCHP or -o option Error: functions predeploy error: Command terminated with non-zero exit code 2 error Command failed with exit code 1.
I was able to deploy by downgrading my firebase tools
npm -g install firebase-tools@12.0.0
I am unable to deploy my production firebase functions due to the same error
i deploying functions Running command: npm --prefix "$RESOURCE_DIR" run build > build > npm run lint && tsc /bin/sh: --: invalid option Usage: /bin/sh [GNU long option] [option] ... /bin/sh [GNU long option] [option] script-file ... GNU long options: --debug --debugger --dump-po-strings --dump-strings --help --init-file --login --noediting --noprofile --norc --posix --protected --rcfile --restricted --verbose --version --wordexp Shell options: -irsD or -c command or -O shopt_option (invocation only) -abefhkmnptuvxBCHP or -o option Error: functions predeploy error: Command terminated with non-zero exit code 2 error Command failed with exit code 1.
I was able to deploy by downgrading my firebase tools
npm -g install firebase-tools@12.0.0
Using firebase-tools@12.1.0 can provide a workaround if you need to deploy to nodejs20.
thank
I am unable to deploy my production firebase functions due to the same error
i deploying functions Running command: npm --prefix "$RESOURCE_DIR" run build > build > npm run lint && tsc /bin/sh: --: invalid option Usage: /bin/sh [GNU long option] [option] ... /bin/sh [GNU long option] [option] script-file ... GNU long options: --debug --debugger --dump-po-strings --dump-strings --help --init-file --login --noediting --noprofile --norc --posix --protected --rcfile --restricted --verbose --version --wordexp Shell options: -irsD or -c command or -O shopt_option (invocation only) -abefhkmnptuvxBCHP or -o option Error: functions predeploy error: Command terminated with non-zero exit code 2 error Command failed with exit code 1.
I was able to deploy by downgrading my firebase tools
npm -g install firebase-tools@12.0.0
Using firebase-tools@12.1.0 can provide a workaround if you need to deploy to nodejs20.
thank you! I just had a WTF moment. I can confirm uninstalling and downgrading to 12.0.0 did the trick.
It seems like there's multiple issues here, although the root of the issues may be the use of npm --prefix
flag with different npm versions. I wasn't able to reproduce this locally. Here are my versions:
To help diagnose further, I'd appreciate if others still seeing this problem could provide additional logs and details like the versions listed above.
@JulienMartel I still have the same issue.
My env:
I used firebase-tools@13.0.1 by installed shell command. Just tried @13.0.2 installed by npm under my project directly, and deploy successfully.
@JulienMartel I still have the same issue.
My env:
- next: 14.0.4
- firebase-tools: 13.0.1
- npm: 10.2.3
- node: v20.10.0
- macOS: Sonoma 14.2 (M1)
Same issue here for a pure JS function that's been deployed before without any issues. Env:
FYI, my current workaround is removing
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
],
from firebase.json.
That being done the deployment works, but be aware that you lose the automatic linting on deploy. I suppose it might even be a more permanent workaround to pre-chain the linting in the function's package.json on deploy.
Per the comments and error logs this issue doesn't seem related to the frameworks integration but rather to the Firebase Functions
FYI, my current workaround is removing
"predeploy": [ "npm --prefix \"$RESOURCE_DIR\" run lint" ],
from firebase.json.
That being done the deployment works, but be aware that you lose the automatic linting on deploy. I supposed it might even be a more permanent workaround to pre-chain the linting in the function's package.json on deploy.
Thank you very much!
Same issue here.
I was using node 16. It worked just by switching to node v20.5.1 (npm v10.0.0).
This help me fix the issue without workarounds:
I reinstalled firebase-cli using npm install -g firebase-tools
I believe previous I installed using curl -sL https://firebase.tools | bash
I am unable to deploy my production firebase functions due to the same error
i deploying functions Running command: npm --prefix "$RESOURCE_DIR" run build > build > npm run lint && tsc /bin/sh: --: invalid option Usage: /bin/sh [GNU long option] [option] ... /bin/sh [GNU long option] [option] script-file ... GNU long options: --debug --debugger --dump-po-strings --dump-strings --help --init-file --login --noediting --noprofile --norc --posix --protected --rcfile --restricted --verbose --version --wordexp Shell options: -irsD or -c command or -O shopt_option (invocation only) -abefhkmnptuvxBCHP or -o option Error: functions predeploy error: Command terminated with non-zero exit code 2 error Command failed with exit code 1.
I'm having the same problem deploying my functions. I've tried downgrading to the versions mentioned above, reinstalling, removing the lint command line in the firebase.json predeploy, and nothing... I'm trying to do it from macOS Sonoma. When I test using emulators, it works normally.
I am unable to deploy my production firebase functions due to the same error
i deploying functions Running command: npm --prefix "$RESOURCE_DIR" run build > build > npm run lint && tsc /bin/sh: --: invalid option Usage: /bin/sh [GNU long option] [option] ... /bin/sh [GNU long option] [option] script-file ... GNU long options: --debug --debugger --dump-po-strings --dump-strings --help --init-file --login --noediting --noprofile --norc --posix --protected --rcfile --restricted --verbose --version --wordexp Shell options: -irsD or -c command or -O shopt_option (invocation only) -abefhkmnptuvxBCHP or -o option Error: functions predeploy error: Command terminated with non-zero exit code 2 error Command failed with exit code 1.
I'm having the same problem deploying my functions. I've tried downgrading to the versions mentioned above, reinstalling, removing the lint command line in the firebase.json predeploy, and nothing... I'm trying to do it from macOS Sonoma. When I test using emulators, it works normally.
I managed to solve it by simply installing firebase-tools in my project directory, not globally:
cd my-project/functions && npm install firebase-tools
I can confirm that lowering the version of firebase tools helped.
sudo rm -rf /usr/local/bin/firebase
npm -g install firebase-tools@12.0.0
i had the same problem.
i had installed firebase with curl -sL https://firebase.tools | bash
command, and seems that caused the issue.
after uninstalling it, and installing firebase via npm
, firebase deploy
works without any error:
curl -sL firebase.tools | uninstall=true bash
npm uninstall -g firebase-tools
i'm using firebase v13.1.0.
I managed to solve it by simply installing firebase-tools in my project directory, not globally:
cd my-project/functions && npm install firebase-tools
This works for me. Thanks!
On MacOS Sonoma 14.1.1 I fixed it by removing the version installed with
curl -sL https://firebase.tools | bash
and installing it via brew
brew install firebase-cli
new mac, node 20, new install through the bash script, deploy failed for the same reason. Has to use answer from https://github.com/firebase/firebase-tools/issues/6446#issuecomment-1925811867 above and reinstall through npm.
It needs more attention from Firebase team. But at least we have workarounds.
Yes, the version of Firebase Tools installed by curl is completely broken. Needs fixing.
Problem still exists. Please!
Can confirm using the bash script caused issues for me. Just delete the globally installed package found with which firebase, and run which again, you'll see it pointing to the right place if you installed with npm.
This worked for my M1 pro, the problem is in the firebase cli:
[!CAUTION] DO NOT INSTALL:
curl -sL https://firebase.tools | bash
.
SOLUTION:
Honestly I don't find having a global install the best approach. Especially since I have multiple projects and one would need to be able to manage the different required versions I simply just include firebase as a dependency and everything is solved with npx firebase deploy --only functions
Solution firebase.json changes
"hosting": { "public": ".next", "rewrites": [ { "source": "**", "function": "nextServer" }
Hello everyone, My app is next.js v14, firebase, auth and firestore
For me using the latest version of firebase-tools and "#firebase deploy --only" functions were working but when I did a full deploy I got this error.
I have done a "firebase deploy" test and got an error
Building a Cloud Function to run this application. This is needed due to:
• non-static route /jobs/[name]/[county]/[id]
• non-static route /search/results
• non-static route /sitemap/[person]
I took a look at my firebase.json in the root folder of my app and found it needed some changes.
Here is my full firebase.json file, please take a look at the "Hosting" section for the solution
{ "firestore": { "rules": "firestore.rules", "indexes": "firestore.indexes.json" }, "functions": [ { "source": "functions", "codebase": "default", "ignore": [ "node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log", "*.local" ], "predeploy": [ "npm --prefix \"$RESOURCE_DIR\" run lint", "npm --prefix \"$RESOURCE_DIR\" run build" ] } ], "hosting": { "public": ".next", "rewrites": [ { "source": "**", "function": "nextServer" } "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ], ], "frameworksBackend": { "region": "europe-west1" } }, "storage": { "rules": "storage.rules" }, "extensions": {} }
[REQUIRED] Environment info
firebase-tools: 12.7.0
Platform: macOS
Next: 13.4.19
[REQUIRED] Test case
Added firebase to an existing, simple next app with a couple of
api
endpoints and the cloud function build fails.[REQUIRED] Steps to reproduce
Add firebase with
firebase hosting init
to a next.js application with server side endpoints. runfirebase deploy
[REQUIRED] Expected behavior
The functions build finishes
[REQUIRED] Actual behavior