简体   繁体   English

使用Brew时出现令人困惑的错误消息

[英]Confusing Error message when using Brew

Every time when I run a brew command, it will give me several error lines at the beginning. 每次我运行brew命令时,它都会在开始时给我几行错误。 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. 现在,我发现如果我对Ruby运行非法命令,它会给我同样的错误消息。 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). 在我看来,您需要先安装ruby,因为您收到的错误来自BASH(它试图将脚本解析为bash,但不会成功)。 Not sure how you managed to install Homebrew without ruby. 不确定如何成功安装没有红宝石的Homebrew。

I've had this error due to RVM being source'ed during bash profile setup. 由于在bash配置文件设置过程中来源了RVM,我遇到了此错误。 It seems the RVM script cannot handle being sourced multiple times into the same shell. 看来RVM脚本无法处理多次被提供到同一shell中的情况。

This was being triggered by commands like ssh-agent , which spawn a new sub-shell, or simply running bash again. 这是由诸如ssh-agent类的命令触发的,它会生成一个新的子shell,或者只是再次运行bash

My solution was to wrap the RVM source'ing in my .bashrc with a check for the $rvm_version variable: 我的解决方案是使用$rvm_version变量检查将RVM源代码包装在.bashrc

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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