invertase / flutterfire_cli

A CLI to help with using FlutterFire in your Flutter applications.
Apache License 2.0
173 stars 49 forks source link

[bug]: _selectFirebaseProject failed with Valid value range is empty: 0 #91

Closed thipokch closed 2 years ago

thipokch commented 2 years ago

Is there an existing issue for this?

CLI Version

0.2.4

Firebase Tools version

11.2.2

Flutter Doctor Output

2022-07-16T04:46:58.7453516Z Doctor summary (to see all details, run flutter doctor -v):
2022-07-16T04:46:58.9449235Z [✓] Flutter (Channel stable, 3.0.4, on Ubuntu 20.04.4 LTS 5.13.0-1031-azure, locale C.UTF-8)
2022-07-16T04:47:06.7762365Z [!] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
2022-07-16T04:47:06.7767234Z     ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
2022-07-16T04:47:06.7769712Z [✓] Chrome - develop for the web
2022-07-16T04:47:06.7771139Z [✗] Linux toolchain - develop for Linux desktop
2022-07-16T04:47:06.7777126Z     ✗ ninja is required for Linux development.
2022-07-16T04:47:06.7778024Z       It is likely available from your distribution (e.g.: apt install ninja-build), or can be downloaded from https://github.com/ninja-build/ninja/releases
2022-07-16T04:47:06.7778856Z     ✗ GTK 3.0 development libraries are required for Linux development.
2022-07-16T04:47:06.7779439Z       They are likely available from your distribution (e.g.: apt install libgtk-3-dev)
2022-07-16T04:47:06.7780643Z [!] Android Studio (not installed)
2022-07-16T04:47:06.7781874Z [✓] Connected device (2 available)
2022-07-16T04:47:06.7782979Z [✓] HTTP Host Availability
2022-07-16T04:47:06.7783403Z 
2022-07-16T04:47:06.7784280Z ! Doctor found issues in 3 categories.

Description

2022-07-16T04:48:12.8475881Z melos run fire:cli
2022-07-16T04:48:12.8478573Z   └> npm install firebase-tools --location=global && \firebase --version && \dart pub global activate flutterfire_cli && \flutterfire --version
2022-07-16T04:48:12.8483105Z      └> SUCCESS

2022-07-16T04:48:12.8776281Z ##[group]Run flutterfire config --verbose --project=***********-dev --out=lib/config/firebase.dart --ios-bundle-id=***.****.****.dev --macos-bundle-id=***.****.****.dev --android-app-id=***.****.****.dev --platforms=android,ios,macos,web --yes
2022-07-16T04:48:12.8777264Z flutterfire config --verbose --project=***********-dev --out=lib/config/firebase.dart --ios-bundle-id=***.****.****.dev --macos-bundle-id=***.****.****.dev --android-app-id=***.****.****.dev --platforms=android,ios,macos,web --yes
2022-07-16T04:48:12.8831872Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2022-07-16T04:48:12.8832144Z env:
2022-07-16T04:48:12.8832396Z   FLUTTER_ROOT: /opt/hostedtoolcache/flutter
2022-07-16T04:48:12.8832710Z   PUB_CACHE: /opt/hostedtoolcache/flutter/.pub-cache
2022-07-16T04:48:12.8833433Z   FIREBASE_TOKEN: ***
2022-07-16T04:48:12.8833650Z ##[endgroup]
2022-07-16T04:48:13.1491773Z Unhandled exception:
2022-07-16T04:48:13.1500645Z RangeError (index): Invalid value: Valid value range is empty: 0
2022-07-16T04:48:13.1501391Z #0      _StringBase.[] (dart:core-patch/string_patch.dart:260:41)
2022-07-16T04:48:13.1501888Z #1      Console.cursorPosition (package:dart_console/src/console.dart:324:15)
2022-07-16T04:48:13.1502400Z #2      Console.windowWidth (package:dart_console/src/console.dart:215:32)
2022-07-16T04:48:13.1502868Z #3      Console.writeLine (package:dart_console/src/console.dart:454:23)
2022-07-16T04:48:13.1503332Z #4      Context.writeln (package:interact/src/framework/context.dart:63:14)
2022-07-16T04:48:13.1503813Z #5      _SpinnerState.render (package:interact/src/spinner.dart:107:13)
2022-07-16T04:48:13.1504311Z #6      Component.interact (package:interact/src/framework/component.dart:48:11)
2022-07-16T04:48:13.1504784Z #7      spinner (package:flutterfire_cli/src/common/utils.dart:160:5)
2022-07-16T04:48:13.1505336Z #8      ConfigCommand._selectFirebaseProject (package:flutterfire_cli/src/commands/config.dart:265:37)
2022-07-16T04:48:13.1505878Z #9      ConfigCommand.run (package:flutterfire_cli/src/commands/config.dart:368:43)
2022-07-16T04:48:13.1506366Z #10     CommandRunner.runCommand (package:args/command_runner.dart:209:27)
2022-07-16T04:48:13.1506887Z #11     CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:119:25)
2022-07-16T04:48:13.1507317Z #12     new Future.sync (dart:async/future.dart:301:31)
2022-07-16T04:48:13.1507731Z #13     CommandRunner.run (package:args/command_runner.dart:119:14)
2022-07-16T04:48:13.1508486Z #14     main (file:///opt/hostedtoolcache/flutter/.pub-cache/hosted/pub.dartlang.org/flutterfire_cli-0.2.4/bin/flutterfire.dart:57:48)

Steps to reproduce

  1. Set FIREBASE_TOKEN environment variable on CI machine
  2. Install firebase tools and flutterfire_cli
  3. run the following command
    flutterfire config --verbose --project=***********-dev --out=lib/config/firebase.dart --ios-bundle-id=***.****.****.dev --macos-bundle-id=***.****.****.dev --android-app-id=***.****.****.dev --platforms=android,ios,macos,web --yes

Expected behavior

Normally I would expect the following

2022-07-15T16:04:01.0082911Z [?25l⠋ Fetching available Firebase projects...
2022-07-15T16:04:04.4314116Z i Found 3 Firebase projects. Selecting project ******-dev.
2022-07-15T16:04:04.4355239Z [?25hi Selected platforms: android,ios,macos,web
2022-07-15T16:04:04.4360690Z Warning - android-app-id (-a) is deprecated. Consider using android-package-name (-p) instead.
2022-07-15T16:04:04.4387477Z [?25l⠋ Fetching registered android Firebase apps for project ******-dev
2022-07-15T16:04:06.2317450Z i Firebase android app ***.******.***.dev registered.
2022-07-15T16:04:08.5409345Z [?25h[?25l⠋ Fetching registered ios Firebase apps for project ******-dev
2022-07-15T16:04:08.6221743Z ⠙ Fetching registered ios Firebase apps for project ******-dev
2022-07-15T16:04:10.3256623Z i Firebase ios app ***.******.***.dev registered.
2022-07-15T16:04:12.5518488Z [?25h[?25l⠋ Fetching registered macos Firebase apps for project ******-dev
2022-07-15T16:04:14.1523603Z ⠋ Fetching registered macos Firebase apps for project ******-dev
2022-07-15T16:04:14.1692232Z i Firebase macos app ***.******.***.dev registered.
2022-07-15T16:04:17.8653748Z ⠋ Fetching registered web Firebase apps for project ******-dev
2022-07-15T16:04:17.9033981Z i Firebase web app method (web) registered.
2022-07-15T16:04:20.0053433Z [?25h
2022-07-15T16:04:20.0057158Z Firebase configuration file lib/config/firebase.dart generated successfully with the following Firebase apps:
2022-07-15T16:04:20.0057687Z 
2022-07-15T16:04:20.0092908Z Platform  Firebase App Id
2022-07-15T16:04:20.0093544Z web       1:***********:web:**********************
2022-07-15T16:04:20.0094144Z android   1:***********:android:**********************
2022-07-15T16:04:20.0150042Z ios       1:***********:ios:**********************
2022-07-15T16:04:20.0150509Z macos     1:***********:ios:**********************
2022-07-15T16:04:20.0150699Z 
2022-07-15T16:04:20.0151135Z Learn more about using this file and next steps from the documentation:
2022-07-15T16:04:20.0151627Z  > https://firebase.google.com/docs/flutter/setup
2022-07-15T16:04:21.0522547Z 
2022-07-15T16:04:21.0523242Z melos run fire:dev
2022-07-15T16:04:21.0525398Z   └> melos run fire:cli && \flutterfire config \  --project=******-dev \  --out=lib/config/firebase.dart \  --ios-bundle-id=***.******.***.dev \  --macos-bundle-id=***.******.***.dev \  --android-app-id=***.******.***.dev \  --platforms=android,ios,macos,web,linux,windows \  --yes
2022-07-15T16:04:21.0526536Z      └> SUCCESS
2022-07-15T16:04:21.0788530Z 

Screenshots

No response

Additional context and comments

This was working 2-3 days ago. I'm not sure if it has to do with the recent updates with( firebase-tools, flutterfire_cli, Melos ) or recent firebase disruptions

thipokch commented 2 years ago

It seems that when I pipe the command with | bash that's causing the issue.

thipokch commented 2 years ago

Recent update to dart_console 1.1.0 (deps for interact) is causing the spinner and cursor issue. It seems to be working fine again after overriding in pubspec.yaml with the lines below and use a dev dependencies to run.

dev_dependencies:
  ...
  flutterfire_cli: ^0.2.4

dependency_overrides:
  dart_console: 1.0.0
flutter pub run flutterfire_cli:flutterfire configure ...

I have yet to file an issue with dart_console's repo

TatsuUkraine commented 2 years ago

@timsneath is there anything you can help with?

timsneath commented 2 years ago

I'll take a look. Thanks for flagging!

timsneath commented 2 years ago

I think I've fixed this in 1.1.2. Could you take a look and see if this solves your issue?

TatsuUkraine commented 2 years ago

@timsneath awesome, thank you! All works for me now

thipokch commented 2 years ago

It's working for me too!