-2

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

paulmbw
  • 9
  • 3
  • 2
    The line `source ~/.bash_profile` should not be in your `~/.bash_profile`. Use TextEdit to open it and remove that line. – Mark Setchell Sep 06 '15 at 17:32
  • Failing that, please click `edit` under your question and paste in the entire contents of your `~/.bash_profile` – Mark Setchell Sep 06 '15 at 17:35
  • The part of line `source ~/.bash_profile` that is. You seem to have combined the two lines of directions into a single line in your `.bash_profile` file. – Etan Reisner Sep 06 '15 at 17:57
  • More generally, see http://stackoverflow.com/questions/29246238/error-message-on-terminal-launch – tripleee Jun 14 '16 at 09:22

1 Answers1

2

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.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432