Unable to upgrade Flutter: Environment variable "FLUTTER_GIT_URL" is unknown

Unable to upgrade Flutter: Environment variable "FLUTTER_GIT_URL" is unknown

Public
Public
Tags
Flutter
Author
Series
Debug Diary
Status
Done
Medium
dev.to

How I Encounter This Issue

When I tried to upgrade Flutter using flutter upgrade, I got the following error message instead of the usual upgrade process.

Error Message

Unable to upgrade Flutter: The current Flutter branch/channel is not tracking any remote repository. Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error
This usually means that your current Flutter installation is not linked to a proper Git remote, so Flutter can’t fetch updates.

Solution

Here are the steps I used to fix it:
  • Clone the official Flutter repository
    • git clone https://github.com/flutter/flutter.git
  • Find the path to Flutter
    • which flutter
  • Copy the path you got after entering this command
  • Go to that Flutter directory
    • cd PASTE_THE_PATH
  • Switch to the stable channel
    • flutter channel stable
  • Run the upgrade
    • flutter upgrade
  • Verify your setup
    • flutter doctor -v
If everything is set up correctly, the error should be fixed and you should see Flutter version has been upgraded.

Additional Information

  • This issue often happens if Flutter was installed from a zip archive or copied from another machine, instead of being cloned from Git.
  • Using the official Git repo ensures that Flutter can track its remote branch and update without problems.

Reference

flutterdevflutterdevUpgrade Flutter