简体   繁体   中英

Confusing Error message when using Brew

Every time when I run a brew command, it will give me several error lines at the beginning. I can't understand what's going on here. Can anyone tell me how I can get rid of the error?

brew
/bin/sh: __rvm_ruby_string_find: line 8: syntax error near unexpected token `('
/bin/sh: __rvm_ruby_string_find: line 8: ` ruby-+([1-9]) | ruby-+([1-9]).+([0-9]) | ruby-1.+([1-9]).+([0-9]) | jruby-[19]*)'
/bin/sh: error importing function definition for `__rvm_ruby_string_find'
/bin/sh: __rvm_project_ruby_env_load_parse_file: line 9: syntax error near unexpected token `('
/bin/sh: __rvm_project_ruby_env_load_parse_file: line 9: ` __rvm_read_lines __variables <( { cat "$1"; echo ""; } | __rvm_sed "${__sed_commands[@]}" )'
/bin/sh: error importing function definition for `__rvm_project_ruby_env_load_parse_file'
/bin/sh: __rvm_remove_without_gems: line 2: syntax error near unexpected token `('
/bin/sh: __rvm_remove_without_gems: line 2: ` __rvm_read_lines __gems_to_remove <('
/bin/sh: error importing function definition for `__rvm_remove_without_gems'

Now I found if I run an illegal command for ruby, it gives me a same error message. So is it because my version problem? 在此处输入图片说明

To my mind, you need to install ruby first as the errors you're receiving are coming from BASH (it is trying to parse the script as bash but doesn't succeed). Not sure how you managed to install Homebrew without ruby.

I've had this error due to RVM being source'ed during bash profile setup. It seems the RVM script cannot handle being sourced multiple times into the same shell.

This was being triggered by commands like ssh-agent , which spawn a new sub-shell, or simply running bash again.

My solution was to wrap the RVM source'ing in my .bashrc with a check for the $rvm_version variable:

if [ -z "$rvm_version" ]; then
    export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

    [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
fi

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM