Search code examples
firebasegoogle-cloud-firestorestripe-paymentsfirebase-toolsfirebase-extensions

"Ref does not have a version" error when trying to install an extension locally using Firebase CLI


I installed stripe/firestore-stripe-payments extension using Firebase Console (https://firebase.google.com/products/extensions/stripe-firestore-stripe-payments) and it works fine.

However, I wanted to install the extension locally so I can have a full testing environment using Firebase Local Emulator Suite.

The issue is that whenever I try to run firebase ext:install stripe/firestore-stripe-payments using both firebase-tools 11.8.1 and 11.14.1, it shows the following error: terminal showing "Error: Ref does not have a version"

I tried looking online but it seems that this error is not common.

Here's my firebase.json:

{
  "database": {
    "rules": "database.rules.json"
  },
  "functions": {
    "ignore": [
      "node_modules",
      ".git",
      "firebase-debug.log",
      "firebase-debug.*.log"
    ],
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint",
      "npm --prefix \"$RESOURCE_DIR\" run build"
    ],
    "source": "functions"
  },
  "emulators": {
    "auth": {
      "port": 9099
    },
    "functions": {
      "port": 5001
    },
    "database": {
      "port": 9000
    },
    "ui": {
      "enabled": true
    },
    "firestore": {
      "port": 8080
    },
    "storage": {
      "port": 9199
    },
    "hosting": {
      "port": 5000
    },
    "pubsub": {
      "port": 8085
    },
    "eventarc": {
      "port": 9299
    }
  },
  "remoteconfig": {
    "template": "remoteconfig.template.json"
  },
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "storage": {
    "rules": "storage.rules"
  },
  "hosting": {
    "public": "./web/build",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

Thank you in advance


Solution

  • I fixed the error by specifying the exact version, according to this GitHub comment.

    The latest version can be found as version in extension.yaml in the official repository, which "source code" link in Firebase's extension page can refer to it, in my case: https://github.com/stripe/stripe-firebase-extensions/blob/master/firestore-stripe-payments/extension.yaml

    So, I used this command and it worked!

    firebase ext:install stripe/firestore-stripe-payments@0.3.1

    It took care of the firebase.json and extensions/firestore-stripe-payments.env automatically.

    If you already installed the extension via console.firebase.google.com, use the following command to import the configuration: firebase ext:export --project=XXXX

    Then, override any attribute in extensions/firestore-stripe-payments.env.local as @darren-ackers mentioned.

    There's a pending PR that covers most of these steps in addition to webhook configuration, here's the relevant file (README):

    https://github.com/stripe/stripe-firebase-extensions/pull/436/files