1

Whenever I open the terminal, this error message pops up:

-bash: /Users/j/.bash_profile: line 2: syntax error near unexpected token 'source'

-bash: /Users/j/.bash_profile: line 2: `if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi source /Users/jackdavis/.bash_profile'

I was wondering how to reset the /.bash_profile so that this does not pop up when I open up terminal.

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
jack d
  • 9
  • 1
  • 3
  • 1
    could you add the content of this file ? maybe the first 5 lines or so ? – Mostafa Hussein Oct 18 '16 at 00:24
  • On MacOS, the default value of this file is *for it not to exist at all*. (Default home directory contents live in `/System/Library/User Template/English.lproj`, for reference). – Charles Duffy Oct 18 '16 at 00:28
  • @MostafaHussein there are only two
    if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
    if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi source /Users/jackd\ avis/.bash_profile
    – jack d Oct 18 '16 at 00:30
  • 1
    Also, StackOverflow is specifically for questions about software development. Inasmuch as this is an end-user support question, it's probably better fitted to [SuperUser](https://superuser.com/), [UNIX SE](https://unix.stackexchange.com/) or [Ask Different](https://apple.stackexchange.com/). – Charles Duffy Oct 18 '16 at 00:30
  • 1
    @jackd, ...if it's just two lines, then delete it. That, or add the missing semicolon or newline after the `fi`. – Charles Duffy Oct 18 '16 at 00:30
  • @CharlesDuffy thank you for your help, I will also redirect any other support questions to any of those – jack d Oct 18 '16 at 00:33
  • @jackd Yes thats correct I have updated my answer. – Mostafa Hussein Oct 18 '16 at 00:33
  • The file you want to modify is `~/.bash_profile`. WIthout the tilde, you are referring to a file in the root directory of your computer, which should not exist, or if it does, you should not have write access to. – tripleee Oct 24 '16 at 06:03

2 Answers2

1

This line needs to modified from:

if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi source 

to

if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

I think source should not be here

source /Users/jackdavis/.bash_profile this should be on a separate line

mklement0
  • 382,024
  • 64
  • 607
  • 775
Mostafa Hussein
  • 11,063
  • 3
  • 36
  • 61
  • Good point, but one mystery remains: the `source` command apparently tries to source `~/.bash_profile` _itself_, which would result in an endless loop. – mklement0 Oct 18 '16 at 02:26
0

I would not delete it, but keep it for reference in case you have a path you need in the future. You can run the command mv ~/.bash_profile ~/.bash_profile_backup

The system will still always have the generic /etc/profile so don't worry.

If you post the bash_profile I might be able to fix it with you. After the new file is created check the old bash_profile to see if there are things you might need and copy them to your new bash_profile.

I noticed that your current user is 'j' whereas the user in the bash_profile is /Users/jackdavis

YairCarel
  • 82
  • 3
  • Yes that worked. Thank you so much. The formatting for the copy and paste of the error message was weird so I forgot to retype the user as jackdavis. – jack d Oct 18 '16 at 00:39