I've been trying to set a flutter path so I don't need to do a temporary path every single time. I'm new to using terminal and Unix (Mac user also) and don't understand how to set my path with the instructions on the site. And it doesn't help that I'm not completely sure where I out my flutter sdk. Would like to know step by step what to do.
- 1flutter.io/setup-linux/#update-your-path - is that what you're talking about?willowis.cool– willowis.cool2018-03-14 01:45:26 +00:00Commented Mar 14, 2018 at 1:45
- Yes but more detailed instructions. I am completely new to this.Terry Feng– Terry Feng2018-03-15 01:54:48 +00:00Commented Mar 15, 2018 at 1:54
- 1Tutorial perhaps?Terry Feng– Terry Feng2018-03-15 01:55:43 +00:00Commented Mar 15, 2018 at 1:55
- You may find your answer here: stackoverflow.com/a/74337608/6921031Sweta Jain– Sweta Jain2022-11-06 16:24:58 +00:00Commented Nov 6, 2022 at 16:24
10 Answers
I'm using Ubuntu 18.04 LTS. Assuming you have successfully downloaded and extracted flutter_linux_v0.5.1-beta.tar.xz (latest update until now) onto your preferred directory.
export PATH=`pwd`/flutter/bin:$PATH Running this command in your ubuntu terminal (Ctrl + Alt + T) adds flutter commands PATH variable to your system path for temporary session. As soon as you close the terminal, the system path is removed.
In order for ubuntu terminal to remember flutter commands permanently, you need to:
1.) open up terminal and cd to $HOME. for eg: user@linux:~$
2.) open the hidden file
.bashrcwith your desired editor. It resides in $HOME.3.) add the following line
export PATH=/home/yourname/flutter/bin:$PATHsomewhere as a newline in.bashrcfile preferably as a last line edit & save file.4.) run
source /home/yourname/.bashrcin terminal to process your recent changes.5.) finally, run
echo $PATHto see flutter dir is in your system path along with other such paths. for eg:/home/yourname/flutter/bin
Now close current terminal and reopen new terminal to check flutter doctor. It should process along with all other available flutter commands everytime now onwards. Thank you ! :)
6 Comments
Windows
Refer to this tutorial https://www.java.com/en/download/help/path.xml
Mac OS
Open or create one the following files:
~/.profile(Compatible with MacOS Catalina).bash_profile(Only if your Terminal uses Bash)
export PATH=$PATH:/flutter/bin Linux
Open or create ~/.bash_profile add the following line at the bottom.
export PATH=$PATH:/flutter/bin Linux (Ubuntu 19.04)
Open ~/.bashrc add the following line at the bottom: (your path may be different)
export PATH=$PATH:~developement/flutter/bin For further documentation
https://flutter.io/docs/get-started/install/macos#update-your-path
Comments
I'm using macOS Catalina version- 10.15.7 and I have updated my $PATH variable by following those steps:
- Optional: Type
echo $SHELLin your terminal. It will tell you which shell you are using. macOS Catalina uses Z shell by default. Output: /bin/zsh - Optional: Type
echo $PATHin your terminal and hit enter. It will show you the existing paths you have already set as path variable. Output: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Library/Apple/usr/bin - As i'm using Z shell i have to open the
.zshrcfile. In my case i'm usingvimeditor. You can also usenanooratomeditor. For opening the file typevi ~/.zshrcin your terminal. - Type
ifor Insert mode. - Type
export PATH="$PATH:[your_flutter_sdk_path_here]/flutter/bin" - To save the file in Vim/vi, press
Esckey then type:wand hitEnterkey. - To quit Vim/vi by press
Esckey then type:xand hitEnterkey. - Finally you need a dot notation to activate it. Type
. ~/.zshrcin your terminal.
Now you can check your path variable by typing echo $PATH in your terminal and hiting enter key.
Output: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Library/Apple/usr/bin:/Users/user/Documents/flutter/bin
Verify that the flutter command is available by running which flutter in your terminal.
Output: /Users/user/Documents/flutter/bin/flutter
Comments
You can add the Flutter path to the system path or to your ~/.profile file.
This will help you as it has more detailed instructions, difference on using .profile vs .bashrc and usage on different shells.
https://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path
Comments
Flutter Path Setup in MAC
Before Setup Clone the git Flutter Folder using below Command
==> git clone https://github.com/flutter/flutter.git -b stable
Step 1: Copy the Path of " Git Flutter Folder" and make PATH variable like below
==> export PATH="$PATH:/Users/myhome/Desktop/Flutter/bin"
Step 2: type "echo $SHELL" in terminal.It will show the type of shell which is using in your Mac
Step 3: If it is bash, type "open .bash_profile" in terminal to open the hidden "rc" file
step 4: once opened, copy the Path variable from step 1 and paste it in .bash_profile file
Step 5: save the file
Step 6:run ==> source $HOME/.bash_profile
Step 7: Now check your path got updated by ==> echo $PATH command
Step 8:once it got listed run ==> Flutter Doctor
Step 9: If error occurs like "flutter commands not found" then "RESTART" your Mac
Now try Flutter Doctor it will work
Comments
For bash profile users
Step 1: open terminal and type
vim ~/.bash_profile Step 2: Type this command (modify your folder path)
Note: I added one new folder(FlutterSDK) in my username
export PATH="$PATH:$HOME/FlutterSDK/flutter/bin" Step 3: Press esc
Step 4: type :wq! command to save this bash file
:wq! Step 5: Close current terminal window & open new window
Step 6: To verify type flutter version command
flutter --version 