Every time I enter a command, or even just hit enter, in Terminal I get this line below the output:

-e:1:in `<main>': undefined method `grep' for #<String:0x007feea31354b8> (NoMethodError)

Odd. Does anyone have any clue as to what this means, and where it's coming from? I'd like to know how to fix it.

  • 1
    Looks like a problem with a command that runs when bash displays the prompt. What are the contents of $PS1 and $PROMPT_COMMAND?
    – chepner
    Mar 7 '14 at 14:21
  • @chepner This is from .bash_profile: PS1="\[$(tput setaf 1)\]\w \[\033[31m\]`ruby -e \"print (%x{git branch 2> /dev/null}.grep(/^\*/).first || '').gsub(/^\* (.+)$/, '(\1) ')\"`\[\033[37m\]\[$(tput sgr0)\]". This is from echo $PROMPT_COMMAND: update_terminal_cwd;
    – Sam
    Mar 8 '14 at 21:33
  • The error message is definitely from the Ruby command. You could remove it; delete the backquotes and everything between them. A more general fix would be to modify the Ruby command to avoid the error, but I don't know enough Ruby to explain how.
    – chepner
    Mar 8 '14 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.