Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools

Amber Cookman
Amber Cookman
12,662 Points

Oops... Messed up my bash profile, halfway fixed...

Hello!

I am working on setting up Gulp and going through the Gulp Basics course. With the video I am on, the teacher showed he uses a Sublime Text cli to create a gulpfile from within Terminal and I remembered that I had bookmarked a link to get that set up for myself.

-

This explanation I found on setting it up seemed more straight forward than the documentation on the Sublime Text website, so it is what I chose to follow.

-

I had to follow the directions to alter the export path in my .bash_profile file, and then the sublime cli was working! However, I went back to Terminal and quickly discovered none of my basic commands worked, and Dr. Google quickly informed me I had improperly set the path.

-

Originally I had the path set like this:

export PATH=/usr/bin:/usr/local/bin

-

Based on a handful of links in my Google results, it seemed fairly unanimous the problem was a missing $PATH in, well, my path. So I added it in to my .bash_profile:

export PATH=$PATH:/usr/bin:/usr/local/bin

-

Then saved, and tried source ~/.bash_profile but was still told the command wasn't found.

-

Another Google search suggested restarting Terminal, then typing the correct path directly into the application, along with updating it in the .bash_profile. Doing this brought back my ability to use basic commands such as ls and cd, but I still get this error whenever I try source ~/.bash_profile to update from the file:

-bash: /Users/cookmanlaptop/.bash_profile: Permission denied

-

So I am wondering if anyone has suggestions for where I can go from here? I'm knee-deep in open browser tabs but no closer to figuring out this last part of my path disturbance. Thanks in advance for your help!

1 Answer

Hi Amber,

The $PATH in 'export PATH=$PATH:/usr/bin:/bin' just means "take whatever value that is currently in this variable and add it to the absolute path that follows". For example lets say $PATH starts out representing one absolute path.

PATH=/usr/bin

Now $PATH allows bash (or whatever shell your using) to find any executables housed in the bin subdirectory of /usr.

PATH=$PATH:/usr/local/sbin

Now $PATH has the original /usr/bin plus the new /usr/local/sbin.

echo $PATH

should now look something like /usr/bin:/usr/local/sbin

Open up your ~/.bash_profile and add this line at the bottom. Without seeing the full file this should set your path variable back to a workable state.

export PATH=$PATH:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin

If that doesn't help I may not fully understand the issue. A good habit to pick up is to first make a backup copy of any config files before making changes that way you have a known working config file should something go wrong

Amber Cookman
Amber Cookman
12,662 Points

Thank you Chris! Unfortunately this did not solve my issue, but I definitely agree that I should've saved my file! Lesson learned. What's weird is it had no export line when I added this in, yet not a single edit I've made to the line, nor simply erasing it has made any difference. My file is mostly bare except what was generated on it's own and a small line of code to add a unicode coffee cup icon to the beginning of each line in my Terminal app. Not really sure how I could've messed it all up with this entirely separate new line!

Happily, the issue is not yet effecting my ability to work or use my Terminal how I need to. Probably just need to schedule some time with an Apple Genius to get myself corrected. :D

Sorry that didn't help. I know it's frustrating. My next suggestion would be to create a new user and copy their .bash_profile (assuming one is created by default) over as a starting point.