我的rvm不工作,可能是因为一个错误。当我打开新控制台时,它会显示:
-bash: /Users/amorfis/.rvm/scripts/cd: line 14: syntax error near unexpected token `('
-bash: /Users/amorfis/.rvm/scripts/cd: line 14: ` cd() { __zsh_like_cd cd "$@" ; }'很难说脚本.rvm/scripts/cd是在哪里调用的。当我从~/.bash_profile中删除此行时
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*没有错误。但是当我发布source $HOME/.rvm/scripts/rvm..。仍然没有错误。
我的系统是Mac OS X 10.9.4
rvm --版本:
rvm 1.25.29 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
更新
~/.rvm/ scripts中的其他脚本:
alias
aliases
autolibs
base
cd
cleanup
cli
completion
cron
db
disk-usage
docs
env
extras
fetch
fix-permissions
functions
gemsets
group
hash
help
hook
info
initialize
install
irbrc
irbrc.rb
list
maglev
manage
migrate
monitor
mount
notes
osx-ssl-certs
override_gem
patches
pkg
prepare
repair
requirements
rtfm
rubygems
rvm
set
snapshot
tools
upgrade
version
wrapper
zsh我的~/.bash_profile看起来像这样:
#...not important stuff
source ~/.bashrc
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*在我的~/.bashrc中,我有这样一行代码(以及其他几行代码):
[ -s "/Users/amorfis/.scm_breeze/scm_breeze.sh" ] && source "/Users/amorfis/.scm_breeze/scm_breeze.sh"当我删除这一行时,错误也就消失了。同样,当我运行source ~/.scm_breeze/scm_breeze.sh时,它仍然没有显示出来
从此处安装Scm breeze:https://github.com/ndbroadbent/scm_breeze
在source ~/.scm_breeze/scm_breeze.sh中有这样一段代码:
if ! type ruby > /dev/null 2>&1; then
echo "Now in if"
# If Ruby is not installed, fall back to the
# slower bash/zsh implementation of 'git_status_shortcuts'
source "$scmbDir/lib/git/fallback/status_shortcuts_shell.sh"
fi我认为"if“语句才是问题所在。所以我就这么做了。在if之前添加了这样的代码:
echo "Now lets try"
if ! type ruby > /dev/null 2>&1; then
echo "trying"
fi
echo "tried"在if内部,作为代码块中的第一行: echo "Now in if“
下面是输出:
Now lets try
tried
-bash: /Users/amorfis/.rvm/scripts/cd: line 14: syntax error near unexpected token `('
-bash: /Users/amorfis/.rvm/scripts/cd: line 14: ` cd() { __zsh_like_cd cd "$@" ; }'所以看起来scm_breeze.sh没问题。问题一定出在.rvm中,但只有在运行scm_breeze.sh时才会出现问题。
更新2:
.rvm/scripts/cd脚本的开头如下所示:
#!/usr/bin/env bash
# Source a .rvmrc file in a directory after changing to it, if it exists. To
# disable this feature, set rvm_project_rvmrc=0 in /etc/rvmrc or $HOME/.rvmrc
case "${rvm_project_rvmrc:-1}" in
1|cd)
# clonned from git@github.com:mpapis/bash_zsh_support.git
source "$rvm_scripts_path/extras/bash_zsh_support/chpwd/function.sh"
# not using default loadign to support older Zsh
[[ -n "${ZSH_VERSION:-}" ]] &&
__rvm_version_compare "$ZSH_VERSION" -gt 4.3.4 ||
{
cd() { __zsh_like_cd cd "$@" ; }
popd() { __zsh_like_cd popd "$@" ; }
pushd() { __zsh_like_cd pushd "$@" ; }
}发布于 2019-02-20 07:08:09
我想将此作为评论添加进来,但我没有这样做的声誉。我尝试了blob的答案,但它不起作用。
我没看到Riaan Burger说的"scm_breeze-line“有人想出这个问题的答案了吗?
我的错误几乎是一样的:
/Users/myusername/.rvm/scripts/cd:14: defining function based on alias `cd' [ruby-2.3.3]
/Users/myusername/.rvm/scripts/cd:14: parse error near `()'第14行也是这样说的:
11 [[ -n "${ZSH_VERSION:-}" ]] &&
12 __rvm_version_compare "$ZSH_VERSION" -gt 4.3.4 ||
13 {
14 cd() { __zsh_like_cd cd "$@" ; }
15 popd() { __zsh_like_cd popd "$@" ; }
16 pushd() { __zsh_like_cd pushd "$@" ; }
17 }发布于 2014-11-10 04:05:47
我刚刚遇到了同样的问题。解决方案是确保rvm行在所有scm_breeze行之后执行。
发布于 2016-03-22 05:11:38
今天遇到了同样的问题,但在我的情况下,这个问题与scm_breeze无关。如果有人无意中从谷歌或其他地方找到了这个答案,也许它会对你有所帮助。
在从Win7切换到OSX后不久,我一直在愉快地修改任何东西,而不需要理解我在做什么。其中,我以根用户身份编辑了.bashrc (不是profile中的那个,而是位于/etc/.bashrc中的那个),并像这样给cd起了别名:
alias cd='cd -P'在安装RVM之前,它从来没有遇到过问题,所以如果您像我以前一样对root感到高兴,那么可能值得检查一下您是否在过去给自己留下了这样的礼物。
我已经将这行代码移到了~/.bash_profile中,从那时起,RVM就可以正常运行了。
https://stackoverflow.com/questions/25606430
复制相似问题