Rails控制台没有运行?

时间:2016-06-21 16:30:14

标签: ruby-on-rails ruby rails-console

刚开始从Hartl的教程中学习编程。我最近将Ruby更新到2.3.1(使用Rails 4.2.6),我试图运行控制台但是我收到了这个错误:

Carloss-MBP:sample_app carlosgrijalva$ rails console
/Users/carlosgrijalva/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- rails/commands (LoadError)
from /Users/carlosgrijalva/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/carlosgrijalva/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/carlosgrijalva/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
from /Users/carlosgrijalva/workspace/sample_app/bin/rails:9:in `<top (required)>'
from /Users/carlosgrijalva/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
from /Users/carlosgrijalva/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `block in load'
from /Users/carlosgrijalva/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/carlosgrijalva/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
from /Users/carlosgrijalva/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/carlosgrijalva/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'

不完全确定这意味着什么。我注意到它提出了Ruby 2.3.0,我没有正确更新Ruby吗?我应该重新安装宝石吗?

2 个答案:

答案 0 :(得分:0)

安装新版本的Ruby后,您还需要安装宝石。如果您使用的是bundler,那么只需运行:

# In your folder with `Gemfile` file.
bundle install

答案 1 :(得分:0)

关于ruby问题,您需要使用RVM或RBENV更改系统上的ruby版本。

使用RVM:

rvm use ruby-2.3.1 --default

使用RBENV:

rbenv global 2.3.1

然后运行:

bundle install