Rails server not running after updating to ruby 2.1.4

五迷三道 提交于 2019-12-04 02:30:40

问题


I was using rails 4.1.7 with ruby 2.0.0 and have developed an application. Recently upgraded to ruby 2.1.4 and made that as "Local" setting using rbenv. Now after doing "gem install rails", everything installed well.

Question is now if I try to run server, i am getting error "Could not find rake-10.4.0 in any of the sources Run bundle install to install missing gems."

bundle show rake reveals that its installed under "bundle show rake /Library/Ruby/Gems/2.0.0/gems/rake-10.4.0"

Shouldn't this be under 2.1.4?


回答1:


Use rvm or rbenv to change ruby and gem space to another one. If you will begin usage of the them do the following (NOTE: If you already use one of them, just begin with point 2):

  1. Install rvm with ruby:

    $ \curl -sSL https://get.rvm.io | bash -s stable --ruby
    

    or install rbenv, and then install ruby, and make it global:

    $ \curl https://raw.githubusercontent.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash
    $ rbenv install 2.1.4
    $ rbenv global 2.1.4
    
  2. Enter to the project, create two files .ruby-version with just installed version of ruby (in example 2.1.4), and .ruby-gemset with name of your project:

    $ cd project-folder
    $ echo "2.1.4" > .ruby-version
    $ echo "your-project-name" .ruby-gemset
    
  3. Fix Gemfile with newly intsalled version of ruby adding a line:

    ruby '2.1.4'
    
  4. Reenter to the project folder, and rvm will generate its wrappers:

    $ cd .. ; cd project-folder
    
  5. Issue gem installation:

    $ bundle install
    


来源:https://stackoverflow.com/questions/27265604/rails-server-not-running-after-updating-to-ruby-2-1-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!