Reputation: 13
I'm trying to install Homebrew via Bash, and I'm very new to using the terminal for things like this. I was using this tutorial for the install: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-homebrew-on-macos#step-3-%E2%80%94-installing-and-setting-up-homebrew
I got to the step where I'm updating the PATH variable, I put in the wrong path to the folder I want my Homebrew files stored to. Here's what I get now when I try to look at my Bash profile:
$ source ~/.bash_profile
-bash: export: `mac/applications/Homebrew:/name': not a valid identifier
$ nano ~/.bash_profile
-bash: nano: command not found
I've tried using the answer from this question: How to edit corrupted bash profile but it didn't work. When I use /usr/bin/vim ~/.bash_profile
I get this result:
export PATH=/name my mac/applications/Homebrew:$PATH
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"~/.bash_profile" 2L, 54C
This doesn't seem to be the normal Bash profile editor, and I am unable to remove the incorrect PATH variable from this screen. Any ideas?
Upvotes: 1
Views: 943
Reputation: 614
cp ~/.bash_profile ~/dead_bash_profile
cp /etc/profile ~/.bash_profile
This will probably induce screams of horror from other users here, but it's one of those fun *nix solutions which will either work perfectly, or fail catastrophically. If you're feeling less adventurous, use /etc/skel/profile instead of /etc/profile, if it exists.
This will do two things for you.
a} It will give you back a temporary working .bash_profile for now, which you very much need.
b} It will preserve the corrupt bash profile in a copy, until you have learned enough about terminal use more generally, that you can come back and figure out what is wrong with it. The reason why that is important, is because a .bash_profile with a corrupt PATH line probably still contains other things which you will want to keep, so just nuking it from orbit isn't necessarily a good idea.
If you want to learn more about use of the terminal, (and you should, both for your own benefit, and because it's a dying art which needs new students) then I recommend study of what you will find at the following two links:-
https://tldp.org/LDP/abs/html/
https://www.amazon.com/Ed-Mastery-Standard-Unix-Editor-ebook/dp/B07BVBSDNZ
Upvotes: 0
Reputation: 141930
export PATH=/name my mac/applications/Homebrew:$PATH
Use quotes around arguments with spaces. You should do:
export PATH="/name my mac/applications/Homebrew:$PATH"
This doesn't seem to be the normal Bash profile editor, and I am unable to remove the incorrect PATH variable from this screen. Any ideas?
It seems like a normal expected output from vim
editor. Use a different more beginner friendly editor if you're not familiar with vim
. Any text editor will be fine.
Upvotes: 1
Reputation: 8456
It looks like vim
is showing you a .bash_profile
with just the single line.
Set a decent minimal value for path first, by typing this line in bash:
$ PATH=/bin:/usr/bin
Assuming nano
is installed in /usr/bin
, just nano .bash_profile
should work again.
Otherwise, just mv .bash_profile .bash_profile.saved
or, if you're sure it contains just that one line, rm .bash_profile
to get rid of it entirely.
Upvotes: 1
Reputation:
I don't know what the "normal Bash profile editor" is. You can use your editor of choice (vim, nano, emacs, etc) to edit your .bash_profile which is just a plain text file. In this case you may want to just delete the line entirely, of if that is the only thing in the file as the above suggest, you could delete it with rm .bash_profile
.
Upvotes: 0