zsh: permission denied when trying to use flutter - flutter

I have been working with flutter for a week now and it runs okay, however I can't use commands such as flutter doctor or flutter upgrade on my terminal nor Android studio. Whenever I try to run a flutter command I get
zsh: permission denied: /Users/name/flutter/bin.
I tried adding the source to nano ~/.zshrc and export PATH, but nothing worked.

I faced this issue when setting up Flutter on my new mac, even after setting the PATH correctly. Turns out i installed the wrong SDK (Window). So make sure to install the correct Flutter SDK on your respective OS.
For MacOS :
https://flutter.dev/docs/development/tools/sdk/releases?tab=macos
For Window :
https://flutter.dev/docs/development/tools/sdk/releases?tab=windows

Make sure you've installed the correct SDK for your machine. For me I had installed Flutter's Windows SDK on my Mac machine.
For macOS : https://flutter.dev/docs/development/tools/sdk/releases?tab=macos
For Window: https://flutter.dev/docs/development/tools/sdk/releases?tab=windows

If you added the path and sure that you have downloaded the correct os files and still get the error:
Go to flutter folder
Empty folder
Open terminal and go to the flutter folder
git clone https://github.com/flutter/flutter.git -b stable

Run below command in the terminal, it worked for me
export PATH="/<full-path-of-flutter-folder>/bin:$PATH"

add the sudo prefix to your command. I guess you are not the admin.
eg: sudo flutter doctor

Related

Cannot Create Flutter Project in Android Studio due to missing pubspec.yaml

Whenever I create the Create new Flutter Project in android studio,
It's always throwing out this error: Please help.
Could not find a file named "pubspec.yaml" in "/Users/<usrname>/AndroidStudioProjects/inventory_system". pub get failed (66; Could not find a file named "pubspec.yaml" in "/Users/<usrname>/AndroidStudioProjects/inventory_system".)
First of all make sure your flutter is properly installed on your system. Faced the same issue. Try checking your installation and make sure everything is installed properly. Use this link: https://flutter.dev/docs/get-started/install
Just uninstall android as well as flutter. Try installing them again. First download and install Flutter. Then download and install Android Studio. Follow the proper installation process. I guess your issue is because of the unproper installation.
After flutter installation, open the folder where you have installed it, and open the file flutter_console which is a batch . It will open a console and then type:
flutter doctor
This will show you whether all the installation is properly carried out or not. But a better way is to perform proper installation.
Also you need to set environment variable after the installation.
Here is what happened with me when I installed flutter and android. This is just to show you the issue I had faced after installation
I then followed what was been said as error and got my flutter and android studio working.
Open the terminal.
Create the folder for your project by typing the command:
mkdir my_awesome_project
Navigate to the created folder:
cd my_awesome_project
In the folder type the command for project creation:
flutter create myawesomeproject
Open the AndroidStudio and then open the created folder.
Now you are ready to run and develop your app.
the easiest and simplest way to create new flutter project is to add flutter plugin to android studio/vs code and selecting SDK dir and then you can simply create new flutter project by clicking on buttons
and you can check flutter official guide

Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. Flutter 2.0

I updated My flutter Version from 1.22 to 2.0. There are some errors in Flutter Doctor. How Could I solve this. That happen Afer Updated my Flutter Version.
I am Using Android Studion 4.1.2, Ubuntu 20.04.2 LTS(64 bit)
For Ubuntu 20.04, chromium is managed by snap. I set the environment variable as shown below.
CHROME_EXECUTABLE=/snap/bin/chromium
export CHROME_EXECUTABLE
Try 'type chromium' to make sure of the location on your system. I assume something similar will work for chrome.
For ones who use MacOS and with another chromium-based browser than Google Chrome (Brave in my case). You can set in .zshrc or .bashrc
export CHROME_EXECUTABLE="/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
After that, don't forget to source ~/.zshrc or source ~/.bashrc in the current terminal window.
flutter doctor -v
Now, "Chrome" will be seen as "Brave".
I had the same error in Windows 10, Using VS Code even after setting CHROME_EXECUTABLE system environmental variable to the path of chrome.exe. I solved it by removing the double quotes around the path:
Even though you have a google chrome app in your system. It may have command like google-chrome-stable or chrome or any name to open chrome browser from terminal. Just duplicate the file with google-chrome name in /usr/bin/
Eg: I have google-chrome-stable as executable so my approach is like
sudo cp /usr/bin/google-chrome-stable /usr/bin/google-chrome
You may have bin in snap folder or some other folder depending on your installation way
If you're not having chrome as executable from terminal then create a symbolic link. Find your chrome binary file and use this command
sudo ln -s $PATH/[google-chrome-bin] /usr/bin/google-chrome
Replace [google-chrome-bin] with your binary file name
I'm on a Chromebook. I installed Flutter and Android Studio. When I ran $flutter doctor -v, I got the same error message that you got.
I didn't need to export the file path to my path environment. I just needed to install Chrome so that Flutter could find it on my Chromebook.
Here was the command that worked for me:
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
Then I installed it using the Linux beta command (right click on the downloaded file, install using Linux beta). It installed it to this directory:
/usr/bin/
(Alternatively, for the install, I could've used this command:
sudo apt install ./google-chrome-stable_current_amd64.deb)
I ran flutter doctor -v and now it finds Chrome.
you can export PATH in your .bashrc or .zshrc if you use Linux or MAC OS
you can found installed chrome PATH using which
for example
which google-chrome
# example result : /opt/google/chrome/google-chrome
then add to .zshrc or .bashrc like this
# Chrome PATH
export PATH=$PATH:/opt/google/chrome
then restart source
source .zshrc # change if you use .bashrc
running the flutter doctor
you will see the output like this
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.1, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version
30.0.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.2)
The answers here have helped me setup Flutter on Mac with Microsoft Edge instead of Chrome.
For that, you simply run from your terminal:
export CHROME_EXECUTABLE="/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
If you want to make this permanent, you should add the above line to the file
~/.zshenv or ~/.zshrc
Then save and restart terminal.
For Linux users, you can add Edge Browser like this...
first, add this path in .bashrc file path
PATH=$PATH:/usr/bin/microsoft-edge-stable
then execute this command
export CHROME_EXECUTABLE="/usr/bin/microsoft-edge-stable"
For MacOS Users
cd to /Users/<your user>
sudo nano ~/.zshenv
Add the following:
export PATH="$PATH:/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
export CHROME_EXECUTABLE="/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
Save the file and restart the IDE terminal
Run flutter doctor
For MacOs User (Vivaldi Browser)
This command sets your PATH variable for the current terminal window only. To permanently add CHROME_EXECUTABLE to your path
export CHROME_EXECUTABLE="/Applications/Vivaldi.app/Contents/MacOS/Vivaldi"
To permanently add CHROME_EXECUTABLE to your path
Open (or create) the rc file for your shell. Typing echo $SHELL in your Terminal tells you which shell you’re using. If you’re using Bash, edit $HOME/.bash_profile or $HOME/.bashrc. If you’re using Z shell, edit $HOME/.zshrc. If you’re using a different shell, the file path and filename will be different on your machine.
If you are using zsh create .zshrc enter a command touch .zshrc which will create a .zshrc file at your hardisk and vice versa for bash.
Go to your finder and press shift + command + H after that again hit a command shift + command + . you will find .zshrc file.
now open .zrch file and add your path
CHROME_EXECUTABLE="/Applications/Vivaldi.app/Contents/MacOS/Vivaldi"
and restart your terminal and you are done.
in my case it was because the name of my chrome was "google chrome 2.app"
i renamed it to "google chrome.app"
You can also try with just chrome instead of google-chrome.

Flutter plugin mot installed still occurs even if I have installed it

I am working on Windows so the following command does not work.
ln -s ~/Library/Application\ Support/Google/AndroidStudio4.1/plugins ~/Library/Application\ Support/AndroidStudio4.1
Any idea?
The last command you mentioned is specifically for MAC users not for Windows.
Anyhow, try the below commands and check if it is working fine.
flutter channel dev
flutter upgrade
flutter config --android-studio-dir="C:\Program Files\Android\Android Studio"
flutter doctor -v
Note: Make sure to change commands based on your directory structure.
I solved the issue with the following ways.
Requirement: You have Git installed on your machine.
Create a folder, for example, src directly in a root path. This procedure is the same as what explained in the flutter official download page. So you now have d:\src for example.
Open powershell or cmd, navigate to d:\src and execute git clone -b master https://github.com/flutter/flutter.git. You need to select master branch here because the stable version still has your issue (as of the time of writing).
Once the cloning finishes, execute flutter doctor -v. The problem should vanish.
You might need to set write access to the flutter folder such that Android Studio can create Flutter project files, etc.

Flutter command prompt not working under Windows

I have downloaded and installed flutter under Windows. After that, I am unable to issue any flutter commands on the Windows command prompt.
Here are the things I have checked/tried so far:
made sure to install Flutter in a directory where my user has write access
made sure that the bin directory is added to the path
uninstalled and reinstalled flutter two or three times
Do you have any idea what else can be the problem?

How do you uninstall Flutter completely and properly from a Mac?

I need to uninstall Flutter completely from my Mac. However, I cannot find any documentation that can help me with that.
Flutter is an SDK that you download and unpack onto a directory in your Mac. There is no automatic uninstall process in the same way that there is no automatic install process. You "installed" it by downloading a zip file and unzipping it. All you have to do is remove the contents of the directory where you unzipped it in.
Even the path addition to be able to call the flutter command from anywhere in your system has to be done manually. If you did that, then you can remove it as well from your shell's PATH.
just rm -rf the sdk folder, or if you just want to clean a corrupt
run the following commands in the Flutter install directory:
git clean -xfd
git stash save --keep-index
git stash drop
git pull
flutter doctor
To find your flutter sdk installed path. use which flutter command and then delete the Flutter SDK folder.
Note: This command only works if you set the path correctly.
The following worked for me:
snap remove flutter
This worked for me actually:
sudo npm uninstall -g flutter-cli