为什么ZSH为我的RVM宝石返回"Command not found"错误?

Jan*_*nis 13 rubygems zsh rvm

我以前运行bashMac Os X Lion附带的默认终端,但最近升级到ZSHOh My Zsh插件.

从那时起,我在使用Ruby gems时遇到了一个奇怪的错误.

本质上,即使安装了宝石,所有宝石都会返回"未找到命令"错误.


以下是我的ZSH终端的一个例子:

  1. 显示RVM ruby​​正在运行.
  2. rvm list 显示我的RVM ruby​​是我想要的默认值.
  3. rvm gem list显示我的宝石已安装,请注意sass宝石.
  4. 运行一个简单的sass --watch命令返回zsh: command not found: sass.
  5. 以防它有帮助,我的$PATH变量输出.

    Jannis-Mac-Pro: /Volumes/Storage2/Sites/git/mathewhawley.com/static
    ? which ruby
    /Users/jannis/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
    
    Jannis-Mac-Pro: /Volumes/Storage2/Sites/git/mathewhawley.com/static
    ? rvm list     
    
    rvm rubies
    
    =* ruby-1.9.2-p290 [ x86_64 ]
    
    # => - current
    # =* - current && default
    #  * - default
    
    
    Jannis-Mac-Pro: /Volumes/Storage2/Sites/git/mathewhawley.com/static
    ? rvm gem list
    Please note that `rvm gem ...` is only an alias to `rvm do gem ...`,
     it might work different as in earlier versions of RVM and will be shortly removed!
     Also note that you do not have to prefix every command with `rvm`, they should just work by itself.
    `rvm do gem list` is deprecated, use `rvm all do gem list` or `rvm 1.9.2 do gem list` instead.
    
    *** LOCAL GEMS ***
    
    addressable (2.2.7, 2.2.6)
    chunky_png (1.2.5)
    compass (0.11.7, 0.11.6, 0.11.5)
    css_parser (1.2.6)
    fssm (0.2.8.1, 0.2.7)
    grid-coordinates (1.2.0)
    haml (3.1.4, 3.1.3)
    htmlentities (4.3.1)
    json (1.6.5)
    nokogiri (1.5.0)
    oily_png (1.0.2)
    premailer (1.7.3)
    rake (0.9.2.2, 0.9.2)
    rb-fsevent (0.9.0, 0.4.3.1)
    rdoc (3.12)
    rubygems-update (1.8.17, 1.8.15, 1.8.13, 1.8.11)
    sass (3.1.15, 3.1.12, 3.1.10)
    stitch (0.1.3.2)
    
    Jannis-Mac-Pro: /Volumes/Storage2/Sites/git/mathewhawley.com/static
    ? sass --style compressed --watch scss:css
    zsh: correct 'sass' to 'case' [nyae]? n
    zsh: command not found: sass
    
    Jannis-Mac-Pro: /Volumes/Storage2/Sites/git/mathewhawley.com/static
    ? echo $PATH
    /Users/jannis/.rvm/gems/ruby-1.9.2-p290@global/bin:/Users/jannis/.rvm/rubies/ruby-1.9.2-p290/bin:/Users/jannis/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin
    
    Run Code Online (Sandbox Code Playgroud)

如果有人知道为什么一切似乎都在运行并被安装,但实际上并没有找到并运行gem命令,我将非常感谢你的帮助.

mpa*_*pis 15

检查你的rc文件

  • .zshenv
  • .zshrc
  • .zlogin
  • .zprofile

其中一个中最有可能在PATHRVM被采购后重置

还有一些oh-my-zsh插件可以破解东西,尝试禁用它们并逐个启用.

  • DOH!我找到了原因,在`.zshrc`文件的最后一行中,我有`PATH = $ PATH:$ HOME/.rvm/bin`而没有在行的开头有`export`.现在,这一行显示`export PATH = $ PATH:$ HOME/.rvm/bin`一切都很好,花花公子.谢谢你的帮助. (5认同)