5

So I’m testing out the CLI today and firebase init with db/hosting selected, and choosing to create a new project, always says Error: Permission denied..

sudo firebase init didn’t help.

firebase-tools version 3.0.3 on OS X 10.11.5.

firebase init

You're about to initialize a Firebase project in this directory:

  /Users/splaktar/Git/tmp

Before we get started, keep in mind:

  * You are initializing in an existing Firebase project directory

? What Firebase CLI features do you want to setup for this folder? Database: Deploy Firebase Realtime Database Rules

=== Project Setup

First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add, 
but for now we'll just set up a default project.

? What Firebase project do you want to associate as default? [don't setup a default project]

=== Database Setup

Firebase Realtime Database Rules allow you to define how your data should be
structured and when your data can be read from and written to.

? What file should be used for Database Rules? database.rules.json

Error: Permission denied.

I've tried the answers here but they did not help. Is this just a bug in the firebase-tools?

Community
  • 1
  • 1
Splaktar
  • 5,506
  • 5
  • 43
  • 74
  • 1
    I have the same issue (also with firebase-tools 3.0.3 on OS X 10.11.5). A possible workaround is to first create a new project from the new Firebase Console ( https://console.firebase.google.com ) and select that project from 'firebase init'. – Pierre De Wilde Jun 25 '16 at 12:40
  • I tried that already without any luck. – Splaktar Jun 25 '16 at 15:08

4 Answers4

2

I have the same issue and this is how I fixed it.

  1. run firebase init
  2. Deselect ❯◯ Database: Deploy Firebase Realtime Database Rules
  3. Go through other steps to setup the initial app, selecting the default for each should work just fine.
  4. run firebase serve

Hope that helps.

Rowland
  • 1,728
  • 1
  • 12
  • 19
2

Sometimes it could happen when .firebaserc file exists.

Remove .firebaserc file and reattempt firebase init.

Chemical Programmer
  • 4,352
  • 4
  • 37
  • 51
1

I was with the same problem, but I was not accessing the right account. After accessed the right account, I created a new project and run "firebase list" (before this not happened) and my new project was there. This solved my problem.

  • I'm not sure that this was my issue, but it would certainly be helpful if the error gave you some indication about this. Perhaps printing the name of the currently logged in user. – Splaktar Aug 14 '20 at 02:27
0

You need to have Owner or Editor IAM permission on the GCP project to use firebase init command.

The firebase init command initializes/enables the project to use Cloud Functions/Hosting etc for Firebase. Owners/Editors have higher permissions that allow APIs to be enabled etc.

it is a first-time task when you starting the development, and then init command can be avoided if you have set up your cloud functions code in VCS for multiple developers or you.

i.e, Usually after writing code, you will replicate the project to other developers, who will then also write code and use firebase use yourprojectid further.

Jijo John
  • 1,368
  • 2
  • 17
  • 31