I'm running Mac OSX 10.12.5. No matter what commands I type into the Terminal, all return -bash: -c: command not found or -bash: -a: command not found or whatever command I'm trying to run. I am extremely new to command-line coding, and I don't even know where to start looking, so forgive me if this question is a duplicate--I literally have no idea how to even begin to troubleshoot this. I've perused some other answers here, but they're all very specific to the circumstance. Can someone point me in the right direction on this?
Related
This question already has an answer here:
How to restore .bash_profile on a mac? None of my unix terminal are working [closed]
(1 answer)
Closed 2 years ago.
I messed up something in my programming a few days ago that screwed up my terminal. My terminal now gives me the a bash error message with basic functions like ls, cd, or ssh. The error looks like this: -bash: ls: command not found , where the "ls" can be replaced with any shell command.
The only way I have found to make my terminal function, is by inputting: export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin" into ever terminal window I open, which can get very tedious.
It also refuses to run Python or Jupyter unless I type the aforementioned command in the terminal window first.
Go files also fail to run in terminal, and gives me a similar error message: -bash: go: command not found. This can be overcome by inputting: export PATH=$PATH:/usr/local/go/bin into the terminal window first.
I'm really worried about what is going on in my computer, and need my terminal to keep functioning in order for me to finish and pass this course (introduction to computer programming). Does anyone have any ideas as to what the problem may be, and how I could go about solving it?
Any help/advice would be greatly appreciated!!!
EDIT: I'm not sure if it is relevant, but I am using a Mac, and these problems started to occur after I attempted to download pygame (I say "attempted" because I never got a working version of pygame installed, though I did download several things in the process (XQuartz and a bunch of stuff from homebrew).
Check your .profile or .bashrc: one of those files might initialize your PATH incorrectly.
Set your PATH manually, then cd ~, and edit those two files to fix your PATH.
I tried to do a little searching myself on this issue, but was unable to find anything helpful. As far as I can tell, whenever I run a command in the terminal that errors, the next command I run will be skipped. A few examples with output:
$ rb
-bash: rb: command not found
$ ls <-------- this command gets skipped
$ cd nonexistent-dir
-bash: cd: nonexistent-dir: No such file or directory
$ cd existing-dir <------ this gets skipped
After the skip, everything resumes as normal until another error. I apologize for the likely awful formatting, this is my first time posting. I feel like I am missing something fairly obvious, but I would appreciate any help or guidance anyone has!
As an additional update, does anyone understand this behavior?
$ kj
-bash: kj: command not found
$ k;l
-bash: l: command not found
What I can note is that the terminal is skipping the input 'k;' between the errors. Unfortunately, I do not know how to further diagnose and solve the issue.
I wanted to start developing in ruby on rails, so I followed few tutorials how to set everything needed. However, I have problem now, because basic commands in terminal window dont work. For example if I type: whoami, ls, etc... error appears saying: -bash: whomami: command not found
when I type: $PATH, this appears: -bash: /Library/Ruby/Gems/2.0.0: is a directory
did I make a mistake while setting up rails environment or it's another problem? If you have similar experiences, please help me to solve this.
Thanks
Try the following command.
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
Better you use this command in you .bashrc file.
I've installed mysql on my laptop.
Now when I launch a terminal window and a unix command like grep, I get this message:
-bash: grep: command not found
-bash: cat: command not found
...
What's happen ? Do you have skills or any ideas to retrieve my precious unix functions ?
I'd like to put this in a comment, but I don't have enough reputation, sorry!
Basic Unix commands like grep or cat are most likely in this folder:
/usr/bin
In order for them to work, you need to have the correct set up of your PATH variable. You might have changed it unknowingly during the installation of mysql.
You can fix this temporarily by trying something like:
export PATH=$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
This will add whatever you have on your PATH at the moment, all the "normal" routes to your precious unix functions. Try the commands again after executing this line in your terminal, and let us know :)
I've used virtualenv to program using my mac terminal for about 1/2 a year w/no issues. Suddenly today I began to get relative path errors when I tried to load python. There was no apparent reason for it, and eventually I tried restarting my computer.
Then I opened a new terminal window, and these new errors were present for the first time:
-bash: eval: line 4: unexpected EOF while looking for matching `"'
-bash: eval: line 5: syntax error: unexpected end of file
I assume the two misbehaviors are related in some way. Any idea what would be causing it? What files could the terminal be looking at that would cause this? AFIAK, I haven't changed anything on which it would depend.
Thx for any advice!
My guess is that a bash startup file (~/.bashrc, or possibly /etc/profile, ~/.bash_profile, ~/.bash_login or ~/.profile) contains a syntax error, and that causes all sorts of errors for other programs because the setup of the environment they expect does not take place.
From the error message it seems like an unterminated string constant, i.e. a missing ".
The bash manual on startup files has information about this.
You can also try to start bash in debug mode (bash -x (interactive shell) or bash -lx ( login shell)) to try to identify the error.