cycle_about
cycle_about

Reputation: 355

Persistent Mac terminal syntax error after Homebrew and Ruby installation

Steps at https://gorails.com/setup/osx/10.10-yosemite to install Homebrew and Ruby onto Mac OS X 10.10.5 includes running these lines in terminal:

brew install rbenv ruby-build  

echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile source ~/.bash_profile

Both lines now run successfully, but this error message is appearing each time terminal is opened (name replaced with “x”):

-bash: /Users/x/.bash_profile: line 12: syntax error near unexpected token `then'
-bash: /Users/x/.bash_profile: line 12: `export PATH="/Users/x/anaconda/bin:$PATH"if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi'

Searching on the error and variations of “terminal opens with bash error” have not turned up a way to remove the error message.

Upvotes: 1

Views: 418

Answers (1)

Holger Just
Holger Just

Reputation: 55718

When you added the code to initialize rbenv to your .bash_profile, it was erronously appended to the last line in that file instead of being added to a new line.

To fix this, edit the file ~/.bash_profile (e.g. by running nano ~/.bash_profile) and add a new line so that the end of the line reads as follows:

export PATH="/Users/x/anaconda/bin:$PATH"
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

You can then save the file and exit the editor with Ctrl+x.

Upvotes: 1

Related Questions