How to add flutter SDK to PATH permanently on ubuntu linux?

安稳与你 提交于 2020-06-17 03:47:07

问题


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.


回答1:


To expand a little on pskink's answer:

1. To edit ~/.profile:

sudo gedit ~/.profile

2. Add a directory to your PATH variable (i.e. where Linux looks for programs):

The last line of your .profile file should look something like this*:

export PATH="/home/tom/Flutter/flutter/bin/cache/dart-sdk/bin:/usr/bin/python:${PATH}"

*Replace "/home/tom/Flutter/flutter/bin/cache/dart-sdk/bin" with wherever Flutter is located on your machine. If you want to add additional folders to your path variable, have a look at where I placed ":/usr/bin/python". Make sure to end with ":${PATH}".

3. Final steps:

When you are done, save the changes, re-login the user, and open a new terminal.



来源:https://stackoverflow.com/questions/60145848/how-to-add-flutter-sdk-to-path-permanently-on-ubuntu-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!