问题
I recently installed Ruby on my mac using this following command:
brew install rbenv ruby-build
I was then instructed to enter this command to add rbenv to bash so it loads every time the terminal is open:
# Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile
Now, everytime I open the terminal I get this error:
Last login: Sun Sep 6 17:30:09 on ttys000
-bash: /Users/pw/.bash_profile: line 1: syntax error near unexpected token `source'
-bash: /Users/pw/.bash_profile: line 1: `if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi source /Users/pw/.bash_profile'
Any ideas to how I can stop this error from showing?
Thanks
回答1:
There should be a single line at the bottom of your ~/.bash_profile that says:
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
That's all. No mention of source anything.
来源:https://stackoverflow.com/questions/32425868/bash-error-when-opening-terminal