zsh: command not found -- no longer have access to basic utilities and all installed softwares or packages from the terminal - macos

Looks like I have managed to scramble my path variable when installing flutter, and now running yarn, shows zsh: command not found: yarn
This was the command I ran that I started experiencing the zsh command not found:
echo 'export PATH="$PATH:[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin >> ~/.zshrc"
I ran the code solution suggested by #devnull https://stackoverflow.com/a/18428774/1766068
PATH=/bin:/usr/bin:/usr/local/bin:${PATH}
export PATH it would work when I open a new tab, but if I should restart the terminal it no longer works.

Open your ~/.zshrc file in a text editor and remove the last line. Then logout and login again.

Related

Terminal modified permanently by vscode

I installed vscode today and followed the steps on tutorials on youtube to set up. My terminal started to act weird after I called python through the terminal and tried to use pip install command but failed. I uninstalled the app, deleted all the relevant files, and tried to reopen the terminal. The terminal still has the same warnings.
I have contacted Apple Tech support and they say my terminal got modified by the app. They asked me to contact the app developer.
I don't know what I did to get where I am now. I would appreciate any help that can bring my terminal back to normal.
Below are the warnings even after I uninstalled the app:
Last login: Wed Jun 10 23:02:45 on ttys000
You have mail.
-bash: Saving: command not found
-bash: ...copying: command not found
-bash: ...saving: command not found
-bash: ...completed.: command not found
-bash: Deleting: command not found
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
ZhouChristinas-MacBook-Pro:~ zhouchristina$
Check your shell's startup script, it looks like you have text there that aren't shell commands. I don't know whether you have bash or zsh as your shell, but check all of these files just to be sure:
~/.bashrc
~/.bash_aliases
~/.bash_profile
~/.bash_login
~/.zshrc
~/.zshenv
~/.zprofile
~/.zlogin
~/.profile
Also look into any files that are sourced by these files.

how to fix "bash: flutter: command not found" error?

I have been working on flutter using VScode with all environment variables set on Windows OS. Now i upgraded the flutter using "flutter upgrade" in Git Bash terminal of VScode to the stable version and now i am not able to use flutter commands in Git Bash terminal of VScode. I wonder where things could have gone wrong , how do i fix it ?
I re-verified that all my environment variables are set correctly according to official documentation. Also flutter commands are running perfectly through flutter console .
Ashish#DESKTOP-3JFCI3M MINGW64 ~/Desktop/Flutter Exercise/test_2
$ flutter doctor
bash: flutter: command not found
Edit: Made changes to the "~/.bash_profile" as mentioned by Sam , still getting the same error . Also i re-checked and the environment variables are set there already. Any ideas what i could do further to fix it ? Thanks in Advance :)
Also when executed command of step no 3. source ~/.bash_profile , output is
$ source ~/.bash_profile
bash: C:DEVLOPMENTflutterbin: command not found
bash: C:DEVLOPMENTflutterbincachedart-sdkbin: command not found```
It's possible that the environment variable, that was previously set, got cleared at some point and that's why the Flutter command is not recognized.
In any case, one way to make sure that Flutter is in your profile is to add it to your path within your ~/.bash_profile (bash profile) file. The ~/.bash_profile is a script gets executed every time you open Git Bash.
Adding Flutter to your Bash Profile
Open your ~/.bash_profile file for editing:
$ nano ~/.bash_profile
Add to the top of your ~/.bash_profile file, the following lines:
# Add Flutter to PATH
PATH=/path/to/flutter/bin:$PATH
# Add Dart to PATH
PATH=/path/to/flutter/bin/cache/dart-sdk/bin:$PATH
Replace /path/to/flutter, with the absolute path of your Flutter installation directory.
Apply the changes:
$ source ~/.bash_profile
Ensuring Git Bash is opened for non-login shells
(Credit: Charles Duffy)
$ echo "source ~/.bash_profile" >> ~/.bashrc

"flutter: command not found" in ubuntu

I'm having trouble with installing Flutter on ubuntu.
Attached is an image of my terminal with the steps I've followed, and the files associated with the flutter directory.
I've followed the steps shown on https://flutter.io/docs/get-started/install/linux and also tried to install with git clone.
https://i.stack.imgur.com/ltmNd.png
I think your problem is in the pwd part of the export command.
Replace the single quotes in 'pwd' with Backtick/back quote (``) like this
export PATH="$PATH:`pwd`/flutter/bin"
EDITED
Above command will just work until you close the terminal.
To make the change permanent you have to edit the .bashrc (or .zshrc, etc), using a text editor like vim, gedit or nano and place the same command at the end of the file.
vim ~/.bashrc or nano ~/.bashrc
Add the next line at the end of the file
# Add flutter to the path
export PATH="$PATH:`pwd`/flutter/bin"
Restart your terminal and verify that your PATH was set correctly with the echo $PATH command
Good luck!!
I am using Linux 18.04 version.
first, add the flutter path in .bash_profile as
export PATH="$PATH:(''flutter path)/flutter/bin"
I have this problem.run the following command in the terminal
source '(flutter path)'.bash_profile'

I have to type export PATH=~/anaconda/bin:"$PATH" everytime I rerun the terminal

I have installed the Anaconda for Mac, but there is something wrong with me:
when I type the commandwhich conda or which ipython, I get conda not found and ipython not find
Then I find this command export PATH=~/anaconda/bin:"$PATH" works for me. It solves the problem above, but everytime I rerun the terminal the problem is still there, I have to type it again.
so I want to find a way to solve the problem fundamentally
I have tried to add it into the ~/.bashrc, ~/.profile, ~/.bash_profile, but these don't work for me.
Try this in .bash_profile
export PATH="$HOME/anaconda/bin:$PATH"
Then try launching a new terminal and running:
echo $PATH
The output should start with /anaconda/bin:
If that still doesn't work... A work around might be to invoke bash after running terminal i.e. type "bash". Which should cause bash to launch with .bash_profile
I run on MacOs Catalina 10.15 and this did the trick for me:
shell is zsh !
$ source /Users/myprofilename/anaconda3/bin/activate
then
$ conda init zsh
the new anaconda documentation also highlights this:
Make sure you're not using ZShell or another form of a shell. If the case you'd have to add the path to your respective shell file, e.g .zshrc.
sudo xed /etc/environment
after open this archive add :/home/youruser/anaconda3/bin
If you're using ZShell follow the steps below:
In your terminal type open ~/.zshrc
Add the following to the file export PATH=/opt/homebrew/bin:$PATH
Save your file and then run the following command source ~/.zshrc
Please note that the homebrew path on Apple silicon is /opt/homebrew/bin

terminal doesn't work after running source ~/.bash_profile

I'm a new python user. When I was installing postgresql and running the following order:
$vi ~/.bash_profile
Add PATH=/usr/pgsql-9.2/bin:$PATH before export PATH.
$source ~/.bash_profile
My terminal became very strange. It seemed that I could not logout of the .bash_profile environment. When I use any basic comments like cd, open, etc., something strange happens.
This is my output:
MynametekiMacBook-Air:~ Myname$ cd Documents/
-bash: dirname: command not found
MynametekiMacBook-Air:Documents Myname$ open ~/.bash_profile
-bash: open: command not found
MynametekiMacBook-Air:Documents Myname$ easy_install pip
-bash: easy_install: command not found
How would I fix this?
If you enter
$nano ~/.bash_profile
you will be able to edit your bash profile, you can remove the line that you added that is causing problems and try again, or see if there is a syntax error in what was entered. Once you've finished your edits you need to press ctl+o then enter to confirm and ctl+x to exit back to the bash prompt.
run /bin/mv ~/.bash_profile ~/.bp. Close your terminal. Reopen and look at the new .bp file with vim ~/.bp. Fix any errors and run mv ~/.bp ~/.bash_profile to revert.
Try export PATH=$PATH:/usr/pgsql-9.2/bin instead of Add PATH=/usr/pgsql-9.2/bin:$PATH. Because it looks like you made so your paths are being overwritten instead of being updated.

Resources