Changing target Firebase ID using firebase-tools CLI - firebase

At the command line...
When I run firebase deploy, I get the following error:
Error: The entered credentials were incorrect.
When I run firebase deploy --debug, I get the following (more detailed) error (and log) shown when you click here. (firebase-debug.log)
When I run firebase deploy --project good-project-id, I get the expected deployment behavior.
When I rerun firebase deploy and firebase deploy --debug I get the same errors already described.
How do I make the proper changes to eliminate the errors when running firebase deploy?
Notes:
I am running Mac OS/X Yosemite v10.10.5
I just ran the NPM installation procedure (via Homebrew) described here.

Look at the contents of your .firebaserc file in your project directory. You likely have a "default" project alias specified. Run firebase list and see if that project id shows up there as well (note it should be the project id, not the instance/subdomain name).
If it doesn't match, that's likely your issue. Another thing you can try is deleting the .firebaserc file and then running firebase use --add to create a new project alias.

Related

Firebase Deployment Error "Error: Functions did not deploy properly."

I have deployed Firebase functions in the past many times. For some reasons, recently (around 2-3 days) I am frequently getting error while deployment. I am using windows to release the code. When I tried with setting up the same project in my Linux system and Mac system the deployment works correctly. What may be the issue for the release from Windows environment.
The following is the issues getting while deployment.
! functions[payment(us-central1)]: Deployment error.
Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.
Functions deploy had errors with the following functions:
admin
cancellation
cost
createStripeCharge
customer
driver
driverLiveTracking
generalSettings
notification
order
payment
To try redeploying those functions, run:
firebase deploy --only "functions:admin,functions:cancellation,functions:cost,functions:createStripeCharge,functions:customer,functions:driver,functions:driverLiveTracking,functions:generalSettings,functions:notification,functions:order,functions:payment"
To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
Following is the deployment command I am using for
"echo Deploying Functions && npm run lint && npm run build && firebase deploy --only functions"
Please share your knowledge over the issue.
Thanks.
I have resolved this issue. On building, I found that the node modules and lib functions are not replacing correctly with the new build. I have done a name changing previously and that are not reflecting in the new build.
Steps followed:
Removed node modules and lib files
Npm install
Npm run serve
And a new build is worked fine as well. I got the same issue using Jenkins build also. I just manually removed the same in server also.
You can find the issue by examining the actual logs. view them using this command
firebase functions:log
The specific issue will be visible there. I sometimes had error as simple as a missing packages in package.json

Google Cloud Build & Firebase Deploy - "An unexpected error has occurred"

I'm using Google Cloud Build to do a deployment to Firebase Hosting when a commit is on master. I'm using the Firebase Cloud Builder, deployed to my project. I've checked permissions in the Cloud Console and Firebase access is enabled.
Everything seems to go well in generating the static HTML for hosting, but at the final build step it fails suddenly with this problem:
Error: An unexpected error has occurred.
Here is the step in my cloudbuild.yaml that fails:
- name: gcr.io/$PROJECT_ID/firebase
args: ['deploy', '--project', '$PROJECT_ID']
id: Deploy to Firebase
The last time that I installed the container was in October. The "An unexpected error has occurred" was solved by others by updating their version of the Firebase CLI. I had to do the same thing in my CD environment in order to get this to work.
Following these instructions in the README:
cd cloud-builders-community/firebase
gcloud builds submit --config cloudbuild.yaml .
The Firebase CLI version was reinstalled and published to my project. Then I was able to retry the build and it worked successfully.
This tripped me up for about an hour yesterday, and I thought it may be helpful to just have the answer documented somewhere.

Where to run gcloud init?

Need to access some gcloud functions in a react project. Should I run gcloud init in the project root folder or within the firebase functions/ folder? Will it interfere with firebase deploy for the functions?
Following this: https://medium.com/#nedavniat/how-to-perform-and-schedule-firestore-backups-with-google-cloud-platform-and-nodejs-be44bbcd64ae
I already have some other firebase functions set up which I would deploy with firebase deploy --only functions. When I got to step 5 of the above tutorial, I got a gcloud command not found. I followed the instructions here: https://cloud.google.com/sdk/docs/#install_the_latest_cloud_tools_version_cloudsdk_current_version
and when it got to step 5 in that, I presume I should be doing it somewhere in the project folder to use that project's specific login? Without running it I get the following error when trying to use:
gcloud functions deploy backup --runtime nodejs8 --trigger-topic YOUR_TOPIC_NAME_HERE
ERROR: (gcloud.functions.deploy) Error parsing [name].
The [function] resource is not properly specified.
Failed to find attribute [project]. The attribute can be set in the following ways:
- provide the argument [--project] on the command line
- set the property [core/project]
The error message is clear. Add --project <project id> at the deploy command or perform a gcloud config set project <project id>.
If you use only firebase, firebase has automatically create a GCP project. Go to https://console.cloud.google.com to view your project name or ID. I think it's also possible to view this information in firebase console.

firebase CLI will not recognize current directory for 'firebase init'

I am following a tutorial on Ionic Angular and it has come to the point where the instructor is having me publish my code to Firebase Hosting. First I used NPM to install the Firebase CLI. Then I was instructed to use the firebase init command. The issue is that the CLI doesn't seem to recognize the current directory that is selected in my terminal.
I run: cd /Users/MyUserName/myProjectsFolder/myProject/
Then I run firebase init and it displays:
You're about to initialize a Firebase project in this directory:
/Users/MyUserName
When I would expect it to read:
You're about to initialize a Firebase project in this directory:
/Users/MyUserName/myProjectsFolder/myProject
A little bit of googling found this page:
https://firebase.google.com/docs/cli/
Which includes this passage:
To initialize a new project directory, change directories in the terminal to your desired project directory and run: firebase init
Based on this I would expect the steps I took to work.
I am confused. Has anyone ever run into this behavior? Can anyone think of a way to get the CLI to function as expected?
Thanks.
Got to folder:
/Users/Username/
Search for a file with name of firebase.json and Delete it.
Reinstall firebase tool with this command (--unsafeper- to avoid
permissions error messages & use sudo):
$ sudo npm install --unsafeper- -g firebase-tools
Then, go to your pubilc folder (you have to create one) which
contains your HTML, JS, images and CSS files and use this command:
$ sudo firebase init
$ sudo firebase deploy
The reset is easy and as mentioned in the firebase
docs:
https://firebase.google.com/docs/hosting/quickstart
The reason is that you must have initiliazed a project in some parent directory (of this myProject folder) in the past. Somehow firebase sees that project in that directory rather than initializing a new project in the current path.
Solution:
Check the parent directories of the path where you want to initialize a firebase project now. Delete / Move the firebase files from that folder and then you should be able to initialize a project in the current directory.
For example:
I also faced the same problem.
I was trying to initialize a project in this path:
D:\Work\Projects\myProject
But somehow it always got initialized in this path:
D:\Work
After some searching it turned out that the reason was that I had initialized a project in
D:\Work directory. I moved those files to another folder and that solved the problem.
I was also facing this problem and windows not able to recognize the firebase. I don't know the exact reason why it was behaving in such a manner but it solved the problem.
1) I installed the firebase-tools using a command on command prompt
npm install -g firebase-tools
and it didn't work.
2) I restarted the machine.
3) then again I executed the same command from step 1) npm install -g firebase-tools
and it worked.
Was trying to do this and discovered a command that allows "firebase" as a command.curl -sL https://firebase.tools | bash This will allow $ firebase login and $ firebase init to work.
I was facing the same issue. After checking the log I figured out that the Authentication token was expired from my firebase cli login session. So I logged out and Logged-In again to the firebase cli using Firebase logout And firebase login command. Problem solved.
To check out your issue go to firebase log using firebase-debug.log command.
And take required steps.

`firebase deploy` just hangs

I'm trying to deploy a site to firebase.
firebase init worked fine. I then ran firebase bootstrap and chose the tetris template. So far so good. But when I run firebase deploy I get Preparing to deploy Public Directory... and then it just hangs forever.
How can I figure out what's going wrong?
Random info in case it helps:
My firebase-tools is version 1.0.1; node is version 0.8.20; npm is version 1.4.23. I ran sudo npm install -g firebase-tools to get the CLI. I'm running on a debian chroot on Android 4.4.3 device. My wifi works fine. On a lark I even tried running sudo firebase deploy in case it depends on ICMP packets or something, but there was no difference.
Firstly, the main reason it's not working is that Node.js version 0.10 or greater is required.
However, even once you've upgraded Node (and I'd recommend getting the latest of firebase-tools too) you're likely to be attempting to deploy the directory that you ran the initial firebase init command from, or at least the folder you specified in the setup (which defaults to the folder you ran the command from).
You should change directory and run the firebase deploy command from the folder that was created by the bootstrap command - which would have been named after the name of the Firebase it was created with, and you can delete the firebase.json file created in the parent directory.
The reason is that firebase init and firebase bootstrap are two different ways of doing the same thing - getting a folder in a deployable state. firebase init is for existing projects with files that will eventually be deployed, and firebase bootstrap is for creating a project from one of the existing templates. By running both, the initial firebase init would have created a firebase.json file containing the settings specified by the prompts, and then the firebase bootstrap command would have created a whole new sub-folder with its own firebase.json for the different settings.

Resources