How to add flutter SDK to PATH permanently on ubuntu linux?
Solution 1
Just edit the .bashrc file in your home directory and add
export PATH="$PATH:$HOME/[path to the directory you have installed flutter]/flutter/bin"
For example:
`export PATH="$PATH:$HOME/Documents/development/flutter/bin"`
Save the file and reopen the terminal
Solution 2
- Modify your .bashrc file (a file that configures your bash shells)
Go to your home folder and press Ctrl+H, to see hidden files. And open the .bashrc file.
Or, alternatively, put this in a terminal:
sudo gedit ~/.bashrc
2. Add a directory to your PATH variable (a global variable which tells your computer where to look for programs)
The last line of your .bashrc file should look something like this*:
export PATH="/home/tom/Flutter/flutter/bin/cache/dart-sdk/bin:${PATH}"
*If you want to add multiple new folders to your PATH variable, feel free to repeat this line as often as you'd like.
- Re-open a terminal
After you modify your path variable you should re-open your terminals.
James Mwase
Updated on December 17, 2022Comments
-
James Mwase over 1 year
I'm very new to using linux as my primary OS. Yesterday I just did a clean install of ubuntu on my pc. I after that I started setting up my desktop. Anything necessary is being installed to run flutter but whenever I run
flutter
flutter: command not found
. I have tried seeing similar questions on stackoverflow but I do not see specific configuration of adding flutter to PATH on ubuntu and it is kinda confusing to me since I'm not experienced with linux for now.When I enter the following
export PATH="$PATH:development/flutter/bin"
command in the terminal, flutter is working but when I close that terminal in which I entered this command and boom, flutter is not being recognized in the console again.What I want is flutter sdk to be added permanently to PATH so that I can access
flutter
command whenever I want in the terminal.I'm using ubuntu
-v Ubuntu 18.04.3 LTS
. Thank you. -
James Mwase about 4 years
# if running bash if [ -n "$BASH_VERSION" ]; then # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc" fi fi # set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi # set PATH so it includes user's private bin if it exists if [ -d "$HOME/.local/bin" ] ; then PATH="$HOME/.local/bin:$PATH" fi export PATH="/home/james/development/flutter/bin:${PATH}"
-
Chinky Sight over 3 years@TomO it does not work for me i am currently on Ubuntu 20.04.1 LTS
-
Tom O over 3 yearsI have modified my answer. It should now work on Ubuntu 20.04.1 LTS.
-
Anoop Thiruonam over 3 yearsHi, you should format your answer. It'd look more nice.
-
Abdulmalek Dery over 2 yearsthis must be the accepted answer because the official docs doesn't include the $HOME variable