how to clear old path for flutter - flutter

I was trying to install flutter in MAC, mistakenly I run export path command many times, now when I echo $PATH it shows all paths which I took mistakenly,
question is, can I clear it or there is no issue of it?

The flutter changes your $PATH variable for running by command line. This $PATH variable can sets in a some files. Please, look these file contents for flutter path.
Try to open these files (if exists)
~/.bash_profile or ~/.zshrc (It changes by your terminal shell)
If you find a line like this, you can remove or change the path of flutter.
export PATH="~/flutter/bin:$PATH"

Related

Flutter command not found and PATH is confusing

I can't use the Flutter command without it saying zsh: command not found: flutter so I can't create a flutter project which is obviously a necessity.
I have installed Flutter by following the instructions on the site. I set the $PATH how it said to in the docs as well, the first time. I removed flutter from the terminal and reinstalled it but I may have made the situation worse.
Here's what I've done so far:
Put the Flutter SDK in my root folder, I know where it is so that is how I set my $PATH in my .zshrc file export PATH="$PATH:/Users/kentwilson/flutter/bin"
I have run echo $PATH | tr ":" "\n" and this is the result:
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/Applications/mongodb-macos-x86_64-4.2.0/bin
/usr/local/share/dotnet
~/.dotnet/tools
Users/kentwilson/Development/flutter/bin
~/flutter/bin
The second from the bottom is from when I had the Flutter installed before.
This is where I am falling apart. I am illiterate when it comes to my computer environment. Everything else I've ever installed required no effort and I miss that.
Decade old MacBook Pro, Catalina 10.15.7 macOS. I know I'm running zsh, I know where the .zshrc is. I have the powerlevel10k installed. Here are my user config lines:
source $ZSH/oh-my-zsh.sh
# User configuration
export MANPATH="/usr/local/man:$MANPATH"
export PATH="$PATH:/Users/kentwilson/flutter/bin"
I've tried it with the double quotes and without. I've tried to find other places that might have a PATH somewhere. Nothing. I've googled a few times and when others simply set the PATH and it fixed the issue but not for me.
Aside from these things, I know nothing. Help me. Thanks.
(Optional)
Find where ~/flutter/bin is added to the PATH and delete the line.
Find where Users/kentwilson/Development/flutter/bin is and delete the line.
You should be able to grep -nr "flutter/bin" * 2> /dev/null from home directory. It might take a while.
(Recommended)
Install FVM https://fvm.app/docs/getting_started/installation
Add following lines to .zshrc
# Flutter
FLUTTER_HOME=$HOME/.fvm/flutter_sdk/
export PATH="$FLUTTER_HOME/bin/cache/dart-sdk:$PATH"
export PATH="$HOME/.pub-cache/bin:$PATH"
export PATH="$HOME/fvm/default/bin:$PATH"
There is a GUI as well for fvm named SideKick which handles multiple flutter versions/channels super easy.

Trying to add path to locate flutter to run "flutter doctor" to solve "zsh: command not found: flutter"

Trying to add path to locate flutter so 'flutter doctor' can be run, to solve zsh: command not found: flutter,
then I found that creating below is first step to solution, but again terminal says nano ~/.bash_profile zsh: command not found: nano
then trying to create bash profile also not working, may be it's existing, but somehow it says below.
$HOME/.bash_profile
zsh: permission denied: /Users/prettygirl/.bash_profile
terminal is given full file access in macOS
restarted my macmini
vscode quitted and restarted,
terminal quitted and restarted
problem still persists. Is there any way to add path variables easily than going through all this hassle with terminal? like macos menu or something to add system path variables?
You're trying to open your bash_profile using nano (text editor) which you don't have installed. You can open that file using any text editor you have. Also, I see you're using zsh and not bash, this means that you should actually edit your ~/.zshrc or ~/.zprofile instead and add
PATH=</path/to/flutter>:$PATH
where you replace </path/to/flutter> with the actual path to flutter on your machine. You can do this if you don't want to add it manually:
echo 'export PATH=</path/to/flutter>:$PATH' >> ~/.zshrc && source ~/.zshrc
again, replacing </path/to/flutter> with your actual flutter path.
This is the only thing that worked for me.
Go to where your flutter folder is and right-click, get info, and copy where the path then paste it in the YOUR_PATH part below.
Open the .zshrc file using the command: nano ~/.zshrc,
Now add the following to the file: export PATH="$PATH:/YOUR_PATH/flutter/bin/"
Save the file by pressing Control + X followed by Enter.
Apply the changes by command: source ~/.zshrc

Swift on Ubuntu 20.04- Need to add a path every time

I am simply trying to install swift on linux
I have downloaded the files from swift.org, extracted .tar files and used export command to include the path after that when I use swift --version it correctly shows the version 5.3.3 but when I close the terminal and try to open the swift command terminal it says command not found.
What is happening here? I need to include the path every time I open the terminal.
The export command just adds the value to path for the current session. When you log out and in again, it will reset.
You need to add this to your shell resource file so that it gets added to the path every time you log in. The file you need to edit will be called .zshrc or .bash_profile or something similar. You should start by opening the command line on your computer and verifying what shell you are running by typing:
echo $SHELL
This will return something like /bin/ksh or /bin/bash or similar. Then do a little internet searching to find out what the resource file is called for that shell. Then edit your resource file to add the Swift path to your $PATH.

Flutter commands not working in the Terminal

I have downloaded flutter and completed my setup am sure its good as I have checked it 5 times and put the correct file path export PATH="$PATH:/Users/KingKimani/Developer/flutter/bin". but I can't run flutter doctor or any flutter command why?
I am currently using the MAC M1 chip.
If you are using zsh do the following.
Open .zshrc file nano $HOME/.zshrc
You will see the commented $PATH variable here
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/...
Remove the comment symbol(#) and append your new path using a separator(:) like this.
export PATH=$HOME/bin:/usr/local/bin:/Users/KingKimani/Developer/flutter/bin:$PATH
Activate the change
source $HOME/.zshrc
You're done !!!
After setting the correct path on the system.
System terminal needs to have latest environment configurations.
Restart/Reload terminal required.
If you are using zsh shell & have save path on .zshrc file.
below command will reload configurations
source ~/.zshrc
Reference

Set Permanent Flutter Path

The steps for modifying this variable permanently for all terminal sessions are machine-specific. Typically you add a line to a file that is executed whenever you open a new window. For example:
Determine the directory where you placed the Flutter SDK. You will need this in Step 3.
Open (or create) $HOME/.bash_profile. The file path and filename might be different on your machine.
Add the following line and change [PATH_TO_FLUTTER_GIT_DIRECTORY] to be the path where you cloned Flutter’s git repo:
$ export PATH="$PATH:[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin"
Run source $HOME/.bash_profile to refresh the current window.
Verify that the flutter/bin directory is now in your PATH by running:
echo $PATH
In mac, you should add it as follows in ".zshrc":
export PATH="$PATH:/Users/matteo/Documents/flutter/bin"
After you have updated the ".zshrc" file, run this command to ensure changes have been notified to OS
source ~/.zshrc
Reference: https://flutter.dev/docs/get-started/install/macos
A similar concept is for Linux system using bash files
I tried a lot of methods but this one permanent solution worked for me like a charm:
open Terminal in your Mac: type:
sudo nano /echo/paths
Add the code to the file:
/users/yourUserName/flutter/bin
Save the file using Control+X and Press Y and Enter
Hope this helps! :)