0

As stated on flutter's website here, I tried setting the environment variable in my Ubuntu 18.10 system. I have saved command in .bashrc but when I source it to run in terminal or run flutter doctor command in a new terminal, it says flutter: command not found.

Surprisingly, when I tried the following command, it worked perfectly but it's temporary:

export PATH="$PATH:`pwd`/flutter/bin"

I want a permanent solution for setting the environment variable.

Output on echo $PATH:

/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

Update: I have added echo "$PATH" in .bashrc right after the export PATH command and it does have a flutter path printed in the terminal when I execute source ~/.bashrc but when I enter flutter doctor after that, it still doesn't work!

5
  • I have also tried this one and faced the same issue. Commented May 11, 2020 at 17:26
  • Also, I have my .bashrc already which also have alias commands which I use very often. They are working fine. I think the problem is with flutter itself. Commented May 11, 2020 at 17:28
  • Could you show exactly what the line in your .bashrc file looks like? And can you confirm you followed step 4 by running source ~/.bashrc? Commented May 11, 2020 at 20:51
  • @MichaelDavies Thanks for coming up for help. I have updated the question. I hope it clears the problem. Commented May 12, 2020 at 15:01
  • No problem. I see you solved it now. Have fun. Commented May 13, 2020 at 16:05

1 Answer 1

1

You are nearly there actually. In your ~/.bashrc file, write the absolute path to flutter/bin. Don't use pwd to resolve the working directory dynamically, because the working directory when the machine is booting up is not necessarily the same as the one you are currently using. To see the full path to flutter/bin, do this from your current directory:

echo "`pwd`/flutter/bin`

Then write the following at the end of your ~/.bashrc file:

export PATH=$PATH:<full path to flutter/bin>

Then run the following command:

source ~/.bashrc

After that, you should be able to run the flutter command, and the command should also be available every time you start up your machine and ssh into it.

Sign up to request clarification or add additional context in comments.

3 Comments

That's what I got from echo `pwd`/flutter/bin -> /home/techmirtz/flutter/bin. I pasted the same in .bashrc as export PATH="$PATH:/home/techmirtz/flutter/bin" and then used source ~/.bashrc. But still, it's not working.
Update: I have added echo "$PATH" in .bashrc right after the flutter export PATH command and it does have a flutter path printed in the terminal when I execute source ~/.bashrc but when I enter flutter doctor after that, it still doesn't work!
The issue has been resolved. I had a source command to set the value of PATH to something else which excluded flutter there in the .bashrc file somewhere after the flutter PATH command which actually sets the path without the flutter at the end of the .bashrc overwriting the flutter path.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.