Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does ZSH return "Command not found" error for my RVM gems?

Tags:

rubygems

zsh

rvm

I used to run the default bash terminal that comes with Mac Os X Lion but have recently upgraded to ZSH with the Oh My Zsh addon.

Since then I get an odd error when using Ruby gems.

In essence all gems return a "Command not found" error even though they are installed.


Here is an example straight from my ZSH terminal:

  1. Shows that the RVM ruby is running as it should.
  2. rvm list shows my RVM ruby to be the default as I want it.
  3. rvm gem list shows that my gems are installed, note the sass gem .
  4. Running a simple sass --watch command returns zsh: command not found: sass.
  5. Just in case it helps, my $PATH variable output.

    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
    

If anyone has an idea of why everything appears to be running and be installed but then doesn't actually find and run the gem command I would appreciate your help.

like image 334
Jannis Avatar asked Mar 05 '12 04:03

Jannis


3 Answers

check your rc files

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

most likely in one of those PATH is reset after RVM was sourced

also some oh-my-zsh plugins can break stuff, try disabling them and enabling one by one.

like image 172
mpapis Avatar answered Nov 05 '22 23:11

mpapis


In my case, this was related to ZSH complains about RVM __rvm_cleanse_variables: function definition file not found , and following the instructions there solved it.

like image 45
Marnen Laibow-Koser Avatar answered Nov 06 '22 00:11

Marnen Laibow-Koser


follow the rvm install doc, i add 2 line in my ~/.zshrc

#add $PATH in path
export PATH="$PATH: /opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/Users/m/Downloads/temp/bin:/Applications/apache-ant-1.9.6/bin:/Users/m/Library/Android/sdk/platform-tools:/Users/m/Library/Android/sdk/tools:/Users/m/Desktop/python/vlfeat/bin/maci64:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/m/bin/FDK/Tools/osx"
source $ZSH/oh-my-zsh.sh
#rvm puby need this, get this file
source ~/.profile
like image 1
defend orca Avatar answered Nov 05 '22 23:11

defend orca