0

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).

sloth
  • 99,095
  • 21
  • 171
  • 219

1 Answers1

2

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • `.profile and .bashrc` may be hidden. Use Ctrl-H to toggle setting. – peterSO Jul 02 '18 at 04:39
  • Thank you for your help, I really appreciate it! Could you also please explain how I would check my .profile or .bashrc, and how I would make sure that my path is correct? Sorry, but I'm still very new to programming (still have less than a month of total experience). Thanks :) – Percy_Cucumber Jul 02 '18 at 04:50
  • @Percy_Cucumber One way to debug that is to add `echo $PATH` after each line of your .bashrc and .profile. That way, at the next login, you can *see* how your PATH evolves, and pinpoint the moment it "goes wrong". – VonC Jul 02 '18 at 04:51
  • Thanks, that seems to have isolated the problem. When I run echo $PATH I get: /Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:’/usr/local/bin:??. I'm guessing that the "??" means that it the path gets lost / goes wrong there? – Percy_Cucumber Jul 02 '18 at 04:57
  • 1
    @Percy_Cucumber simply set the PATH correctly by adding in your file (where you detected the issue) an export PATH=...:/usr/local/bin:/usr/bin:/bin:/usr/sbin (replace ... by the other folders you want to add) – VonC Jul 02 '18 at 05:00
  • This fixes the problem for the individual terminal window but I have to do this in every new window that I open, otherwise I get the same error in the fresh window. – Percy_Cucumber Jul 02 '18 at 05:05
  • @Percy_Cucumber If you type it in the terminal, it'll reappear on the next window. If you add it to the files (or better, fix/delete whatever's messing your path), it'll be permanent. – that other guy Jul 02 '18 at 05:30