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条回答
小情绪 Triste *
2楼-- · 2019-01-05 09:32

Here's what I've done. And the problem is gone. Hence I guess problem solved.

rvm use system

change to the system ruby. remove all gems in it using the command provided and explained here. then I install wanted ruby versions from scratch:

rvm install 1.8.7
rvm install rails -v 3.0.7

then bundle install

for further detail, might need dig into the gem install procedure.

查看更多
劫难
3楼-- · 2019-01-05 09:33

I had this error after updating ruby. I had to run 'bundle install' to fix it.

查看更多
聊天终结者
4楼-- · 2019-01-05 09:37

Rails is not reporting that it isn't installed. Your Debian system is telling you that rails isn't installed. One thing about rvm is that it relies on some complicated bash shell scripting and you sometimes need to start a fresh shell for changes to appear. You should also make sure that the correct rvm shell commands were added to your .zshrc file. Also check your path to make sure the ~/.rvm/gems/... path in included.

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

Try to specify gemset explicitely in your Gemfile:

source 'https://rubygems.org'
ruby "2.2.3"
#ruby-gemset=rails424
查看更多
Juvenile、少年°
6楼-- · 2019-01-05 09:38

For MacOS (High Sierra):

Tokaido is the Rails installer system recommended on the "Getting Started" Rails guide page for Mac OS. But it doesn't just install, it runs its own shell scripts. If you start out using that, which sources its own shell environment, then later start a terminal without launching from the Tokaido shell, this happens, because the "rails" command falls back to the original system rails code on the Mac.

For mine, the 'which rails' command in a normal terminal returns

/usr/bin/rails

But after launching Tokaido's shell, 'which rails' gives this path:

/Users/charlesross/.tokaido/Gems/2.2.0/bin/rails
查看更多
女痞
7楼-- · 2019-01-05 09:39

I had a similar issue, but with rbenv.

I originally installed ruby on bash. Then I played around with .bashrc in VIM, messed that file up, and reset it back to default. In doing so, I unknowingly removed the exported rbenv $PATH. Because of this, my terminal no longer recognized that I had ruby installed.

I revisited the ruby installation page (https://gorails.com/setup/ubuntu/15.04) and tried to set up my rbenv path again with this command:

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc

It failed.

Luckily, I had already switched to zsh (with oh-my-zsh) between the time I messed up my .bashrc and the time I tried to access irb from my terminal.

My solution was to set up the rbenv path per the installation guide, but by replacing all instances of .bashrc with .zshrc like so:

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc

Hope this helps!

查看更多
登录 后发表回答