Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
rvm bash脚本中的语法错误_Bash_Rvm_.bash Profile - Fatal编程技术网

rvm bash脚本中的语法错误

rvm bash脚本中的语法错误,bash,rvm,.bash-profile,Bash,Rvm,.bash Profile,我的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

我的
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\u 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
时。。。仍然没有错误

我的系统是MacOSX10.9.4

rvm——版本:

rvm 1.25.29(稳定版),作者:韦恩·E·塞根,迈克尔·帕皮斯[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\u配置文件
如下所示:

#...not important stuff

source ~/.bashrc

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
#!/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 "$@" ; }
  }
在我的
~/.bashrc
中,我有一行(和其他几行):

当我删除这一行时,错误也消失了。同样,当我运行
source~/.scm\u breeze/scm\u breeze.sh

Scm breeze是从以下位置安装的:

source~/.scm\u breeze/scm\u 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之前添加了此类代码:

echo "Now lets try"
if ! type ruby > /dev/null 2>&1; then
  echo "trying"
fi
echo "tried"
和内部,如果,作为块中的第一行: 回显“现在在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
脚本的开头如下所示:

#...not important stuff

source ~/.bashrc

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
#!/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 "$@" ; }
  }

我也遇到了同样的问题。解决方案是确保scm_breeze行在所有rvm行之后执行。

我刚刚遇到了相同的问题。解决方案是确保scm\u breeze行在所有rvm行之后执行。

今天遇到了相同的问题,但在我的情况下,该问题与scm\u breeze无关。如果有人从谷歌或其他地方偶然发现了这个答案,也许它会帮助你

在从Win7切换到OSX后不久,我很高兴地修改了任何东西,而不必了解我在做什么。除此之外,我还将
.bashrc
编辑为root用户(不是profile中的用户,而是位于
/etc/.bashrc
中的用户),并将其别名设置为
cd
,如下所示:

alias cd='cd -P'
在安装RVM之前,它从来没有出现过问题,所以如果你像我曾经一样快乐,那么也许值得检查一下你过去是否给自己留下了这样的礼物


我已经将上述行移到了
~/.bash_profile
中,从那时起,RVM可以毫无错误地愉快地运行。

今天遇到了相同的问题,但在我的情况下,这个问题与
scm_
无关。如果有人从谷歌或其他地方偶然发现了这个答案,也许它会帮助你

在从Win7切换到OSX后不久,我很高兴地修改了任何东西,而不必了解我在做什么。除此之外,我还将
.bashrc
编辑为root用户(不是profile中的用户,而是位于
/etc/.bashrc
中的用户),并将其别名设置为
cd
,如下所示:

alias cd='cd -P'
在安装RVM之前,它从来没有出现过问题,所以如果你像我曾经一样快乐,那么也许值得检查一下你过去是否给自己留下了这样的礼物


我已经将上述行移到了
~/.bash_profile
中,从那时起,RVM就可以毫无错误地愉快地运行。

我想将此作为一条评论添加进来,但我没有这样做的声誉。我试着从blob中找到答案,但没有成功

我没有看到Riaan Burger所说的“
scm\u breeze
-行”有人找到了答案吗?

我的错误几乎是一样的:

/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 `()'
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      }
第14行也是这样说的:

/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 `()'
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      }

我想加上这个作为评论,但我没有这样做的名声。我试着从blob中找到答案,但没有成功

我没有看到Riaan Burger所说的“
scm\u breeze
-行”有人找到了答案吗?

我的错误几乎是一样的:

/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 `()'
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      }
第14行也是这样说的:

/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 `()'
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      }

手动运行源代码行时没有错误,但从
自动运行时会有错误?
.rvm/scripts/
目录中还有哪些其他文件?您的
.bash\u配置文件
中还有什么内容(就在源代码之前)?@EtanReisner我更新了这个问题。您能包括
光盘
脚本的内容吗?奇怪的是,不相关的源代码行可能会更改错误消息。(我假设您的意思是,如果您离开rvm寻源并仅删除scm寻源,错误就会消失?rvm在该点工作吗?)更新了问题。我安装了zsh,那里没有问题,但是当我运行bash时,在bash中运行
source~/bash\u profile
时出现了错误,但这只是第一次运行。您使用的是什么版本的bash?(我不知道这里会发生什么。)手动运行源代码行时没有错误,但从
自动运行时会有错误。bash_profile
.rvm/scripts/
目录中还有哪些其他文件?您的
.bash\u配置文件
中还有什么内容(就在源代码之前)?@EtanReisner我更新了这个问题。您能包括
光盘
脚本的内容吗?奇怪的是,不相关的源代码行可能会更改错误消息。(我假设您的意思是,如果您离开rvm寻源并仅删除scm寻源,错误就会消失?rvm在该点工作吗?)更新了问题。我安装了zsh,那里没有问题,但是当我运行bash时,在bash中运行
source~/bash\u profile
时出现了错误,但这只是第一次运行。您使用的是什么版本的bash?(我不知道这里会发生什么。)