簡體   English   中英

從Ruby on Rails 4.2.7.1升級到5.0.1-仍嘗試使用Railties 4.2.7.1

[英]Upgrading from Ruby on Rails 4.2.7.1 to 5.0.1 — still tries to use railties 4.2.7.1

我正在創建一個網站,但是不小心安裝了Ruby on Rails版本4而不是版本5,並且想要升級到最新版本,以便使用我系統上版本中當前缺少的一些功能。

我已嘗試遵循此指南:

http://railsapps.github.io/updating-rails.html

我安裝了rvm並按順序運行了所有預備版本,直到本節為止:

rvm use ruby-2.3.1@rails5.0 --create
gem install rails
rails -v

我遇到問題了。 rvm use ruby-2.3.1@rails5.0 --create輸出:

ruby-2.3.1 - #gemset created /home/dev/.rvm/gems/ruby-2.3.1@rails5.0
ruby-2.3.1 - #generating rails5.0 wrappers..........
Using /home/dev/.rvm/gems/ruby-2.3.1 with gemset rails5.0

精細。 Gem install rails也可以正常進行,安裝了所有36個寶石,包括:

Fetching: rails-5.0.1.gem (100%)
Successfully installed rails-5.0.1

Fetching: railties-5.0.1.gem (100%)
Successfully installed railties-5.0.1

但是,當我之后直接運行rails -v ,我得到:

Could not find proper version of railties (4.2.7.1) in any of the sources  
Run `bundle install` to install missing gems.

但是,當我運行bundle install時,系統將恢復為Rails 4.2.7.1。

我需要做一些額外的事情來安裝/鏈接/使用任何Railties 4.2.7.1,並停止將系統還原為Rails的原始版本嗎? 我不太使用Rails,所以我對配置不是特別熟悉。 也許我需要在我的應用程序中更改配置文件?

問題出在Gemfile中,其中包含舊版本號。 我更新為以下內容:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '5.0.1'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.3.13', '< 0.5'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0.6'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 3.0.4'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2.1'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.4.1'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.1', group: :doc

# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

然后運行bundle update然后bundle install ,現在有了Rails 5.0.1。 感謝Iceman建議您查看Gemfile!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM