Home > Net >  Flutter on a MacBook M1: Unable to get flutterfire_cli to work while setting up a Web App
Flutter on a MacBook M1: Unable to get flutterfire_cli to work while setting up a Web App

Time:06-15

I'm VERY new to the Mac OS (I'm running macOS Monterey v12.4) on an M1 Macbook Pro. I have Flutter installed and have built a few sandbox apps with this framework.

I'm trying to build a web application with Flutter and Cloud Firestore and thought it best to use the flutterfire_cli to do some of the configurations but I'm stuck trying to run a specific setup command.

The command that I'm trying to run is "dart pub global activate flutterfire_cli" from a terminal. The output that I get is the following when I run this (the error is at the bottom):

  • ansi_styles 0.3.2 1s...
  • args 2.3.1
  • async 2.9.0
  • ci 0.1.0
  • cli_util 0.3.5
  • collection 1.16.0
  • dart_console 1.0.0
  • deep_pick 0.10.0
  • ffi 1.2.1 (2.0.0 available)
  • file 6.1.2
  • flutterfire_cli 0.2.2 2
  • http 0.13.4
  • http_parser 4.0.1
  • interact 2.1.1
  • json_annotation 4.5.0
  • matcher 0.12.11
  • meta 1.8.0
  • path 1.8.2
  • petitparser 5.0.0
  • platform 3.1.0
  • process 4.2.4
  • pub_semver 2.1.1
  • pub_updater 0.2.2
  • pubspec 2.2.0
  • quiver 3.1.0
  • source_span 1.9.0
  • stack_trace 1.10.0
  • string_scanner 1.1.1
  • term_glyph 1.2.0
  • tint 2.0.0
  • typed_data 1.3.1
  • uri 1.0.0
  • win32 2.6.1 (2.7.0 available)
  • xml 5.4.1 (6.1.0 available)
  • yaml 3.1.1
  • Could not find a file named "pubspec.yaml" in "/Users/myusername/.pub-cache/hosted/pub.dartlang.org/flutterfire_cli-0.2.2 2".

When I try to run the next command according to the documentation here: https://firebase.google.com/docs/flutter/setup?platform=web

That command is "flutterfire configure" from within Android studio I get the following error: "zsh: command not found: flutterfire"

I'm running node version "v16.15.1" and nvm version "0.39.1" with npm version "8.12.1"

Has anyone run into this?

Thanks!

CodePudding user response:

In your termianl run:

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

Then try to use flutterfire command in your project directory.

CodePudding user response:

Thanks for that response shuster. I'm afraid that my environment needed abit more help as there were errors when running several commands. I'll outline the steps I used below to finally get this working.

Steps to resolve the issue

  1. Delete Node and NPM (aka - fresh start)
  2. Reinstall node WITHOUT using the 'sudo' command using NVM
  3. Verify that all versions are in place and working for NVM, NODE and NPM - all good
  4. Was still getting issues with the command from Dart to activate the flutterfire_cli "dart pub global activate flutterfire_cli"
    • I didn't capture the exact error, but there was a complaint about a PUBSPEC.YAML missing
    • I suspected that something was wrong with my Dart installation or cache, so I decided to try clearing the cache
  5. Repairing the cache using this command "dart pub cache repair" produced a "permissions denied" error on the .pub-cache folder
  6. Cleaning the DART cache using this command "dart pub cache clean" produced the same "permissions denied" error on the same folder
  7. So, I went in and deleted everything in that .pub-cache folder manually
  8. I then went back to the terminal and ran the command "dart pub global activate flutterfire_cli" to try and get Dart into a better place
  9. This worked but I got an error message (basically) stating that the path was wrong for a global command and I needed to run "export PATH="$PATH":"$HOME/.pub-cache/bin"
  10. If I ran that PATH command from the terminal, then the Flutterfire CLI would work for that session only but not work in my IDE (Android Studio) unless I ran that same command again inside the IDE
  11. At this point I knew I was very close and needed to figure out how to get this Mac to keep that setting all the time
  12. After some digging into what this "zsh" thing was, I found a post that explained it very well and was able to make the change permanent https://wpbeaches.com/how-to-add-to-the-shell-path-in-macos-using-terminal/  

Hope this helps someone - happy coding!

  • Related