How to Permanently add Flutter to Path in Mac - macos

I know there are many similar answers to this however I have checked them, watched a video on it and tried countless times. I exported the flutter path to the .bashprofile and it is saved as shown in the screenshot however if I close terminal and try using a flutter command like flutter --version or which flutter or even flutter doctor I get flutter not found or zsh: command not found: flutter
How do I fix this so I can permanently use flutter in any directory or path

Please follow the steps below:
Open the Terminal.
Type: nano ~/.zshrc
Type: export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
Press control+x to Exit
Type: source ~/.zshrc
Restart the Terminal.
Verify by typing flutter --version

You're adding the path to .bash_profile but the error says zsh: command not found: flutter.
Look closely at the error, your default shell is zsh and not bash. So adding the path to .bash_profile doesn't help since the path is being looked up for in .zshrc instead.
Here's how you can add the path to .zshrc instead: https://stackoverflow.com/a/11530176/5066615

Adding FLUTTER PPATH to terminal permanently
Step:1
TYPE: echo $SHELL
This will tell which SHELL you are using (bash or Z shell)
Step:2
TYPE: $HOME/.bashrc
If it shows file does not exists, then you need to create new zshrc file
(Only if the above error accours) TYPE: touch ~/.zshrc // this will create a new zshrc file
Step 3:
TYPE: open $HOME/.zshrc //to open the zshrc file
Add the flutter bin path for setting to the terminal permanently in zshrc file
TYPE: export PATH="$PATH:$HOME/development/flutter/bin"
Step 4:
TYPE: source $HOME/.zshrc //to refresh current terminal window
Now u can run flutter cmds without adding path all times

Related

zsh: command not found on MacOS Monterey

I wanted to create a react project and when I executed the command it said zsh: command not found: npx
Then I tried the ls command and it said zsh: command not found: ls.
After setting the export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" command both the ls and npx create-react-app command worked fine and when close the terminal and reopen again, the same command not found error shows.
Is there any permenent fix without setting export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" command
For adding the variables to the path you need to add it to zshrc file for making that variable available locally.
The way you have used will only work until you use it in the same terminal window path only.
To solve the problem, follow these steps:
Goto you home directory
Simultaneously press cmd + shift + (.) Note:the last key is the key of dot
On following step 2, new hidden files will appear in home directory, look for (.zshrc) file and open it using any text editor.
Add your path variable in it, save and then close it.
Example: export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
Open terminal and run the command: "echo $PATH" and see if your added variable is present in the output shown by terminal.
If yes, You are now ready to go to use it from anywhere in terminal now.
This is what worked for me on macOS Monterey,
Although I added the path to ./zshrc and sourced the file, after reopening the terminal the PATH was not exported
I followed these steps to solve this
Created .zprofile with touch .zprofile at the home directory. If the file already exists use that.
Add the required path to this file using vim or nano
eg: export PATH=${PATH}:/Users/Development/HashBaze/flutter/bin
If the above two steps don't work try sourcing both the .zprofile and .zshrc after following the above two steps.
This solution worked for me on macOS Monterey version 12.5

Setting up Flutter in terminal yields a command not found message

I'm trying to setup Flutter on my Mac but when I use the terminal to check the version I keep getting the message "zsh: command not found: flutter"
The steps that I've done to set it up are:
In a terminal window type vim ./zshrc
Paste the export PATH="$PATH:[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin"
code (changing the brackets to the actual file path)
:wq!
Testing the version by typing flutter --version
Is there something I'm missing, or something I'm not doing right?
Your PATH step should likely be:
export PATH="$PATH:[PATH_TO_FLUTTER_GIT_DIRECTORY]/bin"
Note that the directory you want to add to your path is bin, not flutter/bin, relative to the Flutter git directory.
The install instructions for macOS and Linux specify the steps as:
$ git clone https://github.com/flutter/flutter.git
$ export PATH="$PATH:`pwd`/flutter/bin"
Note that the git clone step creates a flutter directory within your current directory, so the path to add is flutter/bin relative to pwd (the current directory).
it can be done with an editor nano or vim which will return a text editor terminal there you can edit path and save,eg
nano .bash_profile
nano .bashrc

Installing flutter bash_profile

I'm trying to install flutter
I need to create with the terminal a file named bash_profile
I tried to create it but each time that I'm trying, I'm getting a bash_profile file with an extension: bash_profile.swo and bash_profile.swp instead of bash_profile.
How can I remove the 2 bash_profile.swo and bash_profile.swp?
thank you
You can simply use echo '' >> .bash_profile.
You can also use the touch command to do it.
Remember that bash_profile file is a occulted file. you probably already have this file, try check it by running ls -la.
and you must to use a 'dot' before 'bash' >> .bash

How to set up packer PATH on Mac Unix

The documentation of packer says: Packer Setup Documentation
on how to set the PATH : How to permanently set PATH in Unix
And I did add :
export PATH=$PATH:~/packer/
in my ~/.zshrc file
however, when I go to type packer on the terminal first time, the dir changes to be ~/packer and when I type packer again I get :
~ packer
➜ packer packer
zsh: command not found: packer
Does anyone have a better clue on how to set up packer's PATH on a Macintosh Unix system?
In OS X you would typically have any exports set in:
~/.bash_profile
If you already have a .bash_profile setup then it will override .profile. Since you're using zsh you might try putting the export in ~/.zprofile.
Please try adding your edits to the ~/.profile file instead of ~/.bashrc file.
To make the new path stick permanently you need to create a .bash_profile file in your home directory and set the path there.
Open terminal on Mac and write nano .bash_profile.
Create the .bash_profile file with a command line editor called nano,If it is already exists then it will open a text editor containing path.
Add the path you require like:
export PATH="/usr/local/node/bin:$PATH"
Save the file in nano by clicking Ctrl+O and confirming the name of the file as .bash_profile by hitting enter. And the Ctrl+X to exit nano.
Then for checking path is set or not just write echo $PATH in terminal. Your path would be there in it.

Torch / Lua after installation is not working

I have followed the following approach in order to install Torch in my machine (Mac).
http://torch.ch/docs/getting-started.html#_
When I am done with the installation, I type:
$ luarocks install image
or $ luarocks lis
or $th
in order to load the th or to make updates on the lua packages. It says "command not found". Do you have any idea how I can resolve this issue?
If you're on a Mac using the bash terminal, make sure that you've permanently added /Users/you/torch/install/bin to your PATH.
To do this:
Navigate in your terminal to the root directory by running the command:
$ cd
Using the text editor of your choice (emacs, vim, etc.) open the .bash_profile file for editing. For example:
$ emacs .bash_profile
Add the following line to the end of the file (replacing 'you' with your Mac username):
PATH=$PATH\:/Users/you/torch/install/bin ; export PATH
Save and exit the text editor
Source the changes by running:
$ source .bash_profile
Check that your PATH has been updated (look for /Users/you/torch/install/bin in the string returned):
$ echo $PATH
To make sure it has been changed permanently, completely quit Terminal, open it and run echo $PATH again
Now try th and it should run Torch!
For more help on PATH:
https://kb.iu.edu/d/acar
The Torch installation (at least for me) added the line . /Users/jb/torch/install/bin/torch-activate to my .profile file, not .bash_profile. I tried adding that exact line to .bash_profile but it didn't work, so based on the recommendations here I got rid of the trailing directory and such.
Have you updated your PATH? It should include something like
/home/user/torch/install/bin
I faced the same issue and following this post deleted and reinstalled everything. However in the end what helped was adding /home/user/torch/install/bin/ to the PATH variable.
I have resolved the issue. I have deleted torch and I have installed it again. I have updated my PATH, and I have ran the $ luarocks install image command. After all of these, I was able to ran $ th command and in general torch.

Resources