Rails keeps telling me that it's not currently

2019-01-05 09:02发布

I use rvm to manage different rubies and their gemsets. My shell is zsh with oh-my-zsh configured with basic settings. Enabled oh-my-zsh plugins are ruby, rails, osx, and git. Here's the command I used to install ruby-1.8.7 and rails-3.0.7.

rvm install 1.8.7
rvm use 1.8.7
gem install rails -v=3.0.7

and then I typed rails and got:

Rails is not currently installed on this system. To get the latest version, simply type:

    $ sudo gem install rails

You can then rerun your "rails" command.

I've tried more thorough installs also, Like reinstall rubygems after switching to ruby-1.8.7, or create a completely new gemset, but with no luck.

Here's the rvm info:

ruby-1.8.7-p352@rails:

  system:
    uname:       "Darwin yicai.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64"
    bash:        "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)"
    zsh:         "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)"

  rvm:
    version:      "rvm 1.8.6 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]"

  ruby:
    interpreter:  "ruby"
    version:      "1.8.7"
    date:         "2011-06-30"
    platform:     "i686-darwin10.8.0"
    patchlevel:   "2011-06-30 patchlevel 352"
    full_version: "ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin10.8.0]"

  homes:
    gem:          "/Users/nil/.rvm/gems/ruby-1.8.7-p352@rails"
    ruby:         "/Users/nil/.rvm/rubies/ruby-1.8.7-p352"

  binaries:
    ruby:         "/Users/nil/.rvm/rubies/ruby-1.8.7-p352/bin/ruby"
    irb:          "/Users/nil/.rvm/rubies/ruby-1.8.7-p352/bin/irb"
    gem:          "/Users/nil/.rvm/rubies/ruby-1.8.7-p352/bin/gem"
    rake:         "/Users/nil/.rvm/bin/rake"

  environment:
    PATH:         "/Users/nil/.rvm/gems/ruby-1.8.7-p352@rails/bin:/Users/nil/.rvm/gems/ruby-1.8.7-p352@global/bin:/Users/nil/.rvm/rubies/ruby-1.8.7-p352/bin:/Users/nil/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/sbin"
    GEM_HOME:     "/Users/nil/.rvm/gems/ruby-1.8.7-p352@rails"
    GEM_PATH:     "/Users/nil/.rvm/gems/ruby-1.8.7-p352@rails:/Users/nil/.rvm/gems/ruby-1.8.7-p352@global"
    MY_RUBY_HOME: "/Users/nil/.rvm/rubies/ruby-1.8.7-p352"
    IRBRC:        "/Users/nil/.rvm/rubies/ruby-1.8.7-p352/.irbrc"
    RUBYOPT:      ""
    gemset:       "rails"

and the gem version is 1.8.10, the latest.

21条回答
成全新的幸福
2楼-- · 2019-01-05 09:59

Restart your terminal and then re-run your rails command

查看更多
小情绪 Triste *
3楼-- · 2019-01-05 09:59

I ran into this issue using rbenv. Turns out gem install rails did in fact install Rails but rails was not recognized as an executable. The fix for me was to run rbenv rehash.

I found this fix and more details on setting up Rails 5 at https://gorails.com/setup/osx/10.11-el-capitan

查看更多
老娘就宠你
4楼-- · 2019-01-05 09:59

I ran into this same issue and none of the answers given helped so I thought I'd share my solution in case it might be useful for someone else.

I was messing around with my .profile and .bashrc files and along the way I messed up my RVM install. Still not sure exactly what I did, but the fix was easy. Just had to run the following command, which cleans up all of your system path settings for RVM:

rvm get [head|stable] --auto-dotfiles

Note that if you're running an old version of RVM this may upgrade your setup, which may not be what you want.

查看更多
登录 后发表回答