Flutterfire throws a dart not found error
Asked Answered
F

5

4

I'm following the flutter + firebase codelab, and I'm stuck at configuring firebase in my android app, I've already installed the flutterfire cli globally on my machine and exported the bin in my path.

export PATH="$PATH:~/source/flutter/bin"
export PATH="$PATH":"$HOME/.pub-cache/bin"

But still, the following error is thrown when I try to use the flutterfire cli.

flutterfire
/home/dio/.pub-cache/bin/flutterfire: 8: dart: not found

This error leads me to believe that dart is not installed on my system but....

dart
A command-line utility for Dart development.

Usage: dart <command|dart-file> [arguments]

Global options:
-h, --help                 Print this usage information.
-v, --verbose              Show additional command output.
    --version              Print the Dart SDK version.
    --enable-analytics     Enable analytics.
    --disable-analytics    Disable analytics.

Available commands:
  analyze    Analyze Dart code in a directory.
  compile    Compile Dart to various formats.
  create     Create a new Dart project.
  devtools   Open DevTools (optionally connecting to an existing application).
  doc        Generate API documentation for Dart projects.
  fix        Apply automated fixes to Dart source code.
  format     Idiomatically format Dart source code.
  migrate    Perform null safety migration on a project.
  pub        Work with packages.
  run        Run a Dart program.
  test       Run tests for a project.

Run "dart help <command>" for more information about a command.
See https://dart.dev/tools/dart-tool for detailed documentation.

Flutter doctor output:

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 2.13.0-0.0.pre.271, on Pop!_OS 22.04 LTS 5.16.19-76051619-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2021.1)
[✓] Android Studio
[✓] VS Code (version 1.66.2)
[✓] Connected device (1 available)
[✓] HTTP Host Availability
Facture answered 2/5, 2022 at 22:34 Comment(0)
G
14

I was facing this same problem, so I looked into the file that stores the code for flutter fire command in bash.

This file is stored in the ~/.pub-cache/bin/ I looked up the code inside this file. What the code basically does is, it passes over whatever command that you have given, to this other command

dart pub global run flutterfire_cli:flutterfire{your command}

So, if you want to run a command say, flutterfire configure, you can run it this way,

dart pub global run flutterfire_cli:flutterfire configure

I hope this answer helps!!.

Gamesmanship answered 16/6, 2022 at 4:55 Comment(0)
F
0

I was able to work around this issue by calling the bin directly, like so:

dart /home/foo/.pub-cache/global_packages/flutterfire_cli/bin/flutterfire.dart-2.17.0-239.0.dev.snapshot configure

This is weird since I'm calling the cli through the same path specified in at ~/.pub-cache/bin/flutterfire

  dart "/home/foo/.pub-cache/global_packages/flutterfire_cli/bin/flutterfire.dart-2.17.0-239.0.dev.snapshot" "$@"
Facture answered 2/5, 2022 at 23:52 Comment(0)
K
0

You can remove the first line from the /home/YOUR_USERNAME/.pub-cache/bin/flutterfire file and the flutterfire command should work properly.

Remove this line:

#!/usr/bin/env sh

Keep the rest

Also, check this post modify path, did not work for me though.

Kilocalorie answered 6/2, 2023 at 8:22 Comment(0)
R
0
  1. First make sure you are in the directory of the project you want to use in flutter
  2. Next install node.js using this link (we used the latest version) : https://nodejs.org/en/
  3. Then install firebase tools using: npm install -g firebase-tools
  4. Make sure that firebase is in your path by running firebase --version
  5. Make sure flutter is in your path way. you can do this by going into finder and locating the flutter sdk. once located, right click click on getInfo, and then you will see "where", then right click and copy path. Go back to the same terminal window and use this command export PATH="$PATH:[PATH_TO_FLUTTER_SDK]/flutter/bin"
  6. Check if it is really in your path by running flutter doctor
  7. Next you want to delete this file called pubspec.lock by running this command rm pubspec.lock
  8. Lastly run this command to install all the tools for flutter fire:
    dart pub global activate flutterfire_cli

You should be able to use it now. Some helpful links to use are https://firebase.flutter.dev/docs/cli/ https://firebase.google.com/docs/cli?authuser=0&hl=en#sign-in-test-cli

Radiculitis answered 26/2, 2023 at 6:26 Comment(0)
C
0

[Linux]

I was facing this issue on Ubuntu, the problem is that the script which essentially stands for the flutterfire command uses #!/usr/bin/env sh as shell, replacing it with #!/bin/bash solved the issue for me.

How to do that:

  1. Navigate in the file explorer to ~/.pub-cache/bin/ and open the flutterfire file in a text editor, alternatively you can use nano ~/.pub-cache/bin/flutterfire
  2. Replace the first line of that file from #!/usr/bin/env sh to #!/bin/bash
  3. Save the file
  4. Run flutterfire command and enjoy ;)
Considerable answered 27/6, 2024 at 22:34 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.