升级rails:从4.x升级到5.2.2

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/diyinqian/article/details/85227339

思路:

修改Gemfile里面的rails版本以及依赖包版本

主要参考网站:

https://rubygems.org/ 这里有各种gem包的版本。

解决方法:

命令行里执行bundle update rails,根据提示修改gemfile里的包版本。下面是我一点点修改的过程:

[email protected]:~/Desktop/se-CourseSelect$ bundle update rails 
Fetching gem metadata from https://gems.ruby-china.com/..........
Fetching gem metadata from https://gems.ruby-china.com/.
Resolving dependencies.............
Bundler could not find compatible versions for gem "rails":
  In Gemfile:
    rails (= 5.2.2)

    rails_admin (~> 0.8.1) was resolved to 0.8.1, which depends on
      rails (~> 4.0)
显然rails_admin版本太低,于是我去把Gemfile里做了改动:gem 'rails_admin', '~> 1.4.2' 

[email protected]:~/Desktop/se-CourseSelect$ bundle update rails
Fetching gem metadata from https://gems.ruby-china.com/..........
Fetching gem metadata from https://gems.ruby-china.com/.
Could not find gem 'rails_admin (~> 1.0.4)' in any of the gem sources listed in your Gemfile.
[email protected]:~/Desktop/se-CourseSelect$ bundle update rails
Fetching gem metadata from https://gems.ruby-china.com/..........
Fetching gem metadata from https://gems.ruby-china.com/.
Resolving dependencies...........
Bundler could not find compatible versions for gem "activerecord":
  In Gemfile:
    paper_trail was resolved to 8.1.2, which depends on
      activerecord (< 5.2, >= 4.2)

    rails (= 5.2.2) was resolved to 5.2.2, which depends on
      activerecord (= 5.2.2)
 显然paper_trail 版本太低,于是我去把Gemfile里做了改动:gem 'paper_trail','~>10.1.0'
  
[email protected]:~/Desktop/se-CourseSelect$ bundle update rails
Fetching gem metadata from https://gems.ruby-china.com/..........
Fetching gem metadata from https://gems.ruby-china.com/.
Resolving dependencies............
Bundler could not find compatible versions for gem "railties":
  In Gemfile:
    rails (= 5.2.2) was resolved to 5.2.2, which depends on
      railties (= 5.2.2)

    rails-i18n was resolved to 4.0.9, which depends on
      railties (~> 4.0)
显然rails-i18n版本太低,于是我去把Gemfile里做了改动:gem 'rails-i18n','~>5.1.2'

[email protected]:~/Desktop/se-CourseSelect$ bundle update rails
Fetching gem metadata from https://gems.ruby-china.com/..........
Fetching gem metadata from https://gems.ruby-china.com/.
Resolving dependencies..............
Bundler could not find compatible versions for gem "railties":
  In Gemfile:
    coffee-rails (~> 4.1.0) was resolved to 4.1.1, which depends on
      railties (< 5.1.x, >= 4.0.0)

    jquery-rails was resolved to 4.3.3, which depends on
      railties (>= 4.2.0)

    rails (= 5.2.2) was resolved to 5.2.2, which depends on
      railties (= 5.2.2)

    rails-i18n (~> 5.1.2) was resolved to 5.1.2, which depends on
      railties (< 6, >= 5.0)

    sass-rails (~> 5.0) was resolved to 5.0.7, which depends on
      railties (< 6, >= 4.0.0)

    web-console (~> 2.0) was resolved to 2.3.0, which depends on
      railties (>= 4.0)
显然coffee-rails版本太低,于是我去把Gemfile里做了改动:gem 'coffee-rails', '~> 4.2.2'
    
[email protected]:~/Desktop/se-CourseSelect$ bundle update rails
Fetching gem metadata from https://gems.ruby-china.com/..........
Fetching gem metadata from https://gems.ruby-china.com/.
Resolving dependencies...................
Using rake 12.3.2
Using concurrent-ruby 1.1.4
Using i18n 0.9.5
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using activesupport 5.2.2 (was 4.2.5.2)
Using builder 3.2.3
Fetching erubi 1.8.0
Installing erubi 1.8.0
Using mini_portile2 2.4.0
Using nokogiri 1.9.1
Using rails-dom-testing 2.0.3 (was 1.0.9)
Using crass 1.0.4
Using loofah 2.2.3
Using rails-html-sanitizer 1.0.4
Using actionview 5.2.2 (was 4.2.5.2)
Using rack 2.0.6 (was 1.6.11)
Using rack-test 1.1.0 (was 0.6.3)
Using actionpack 5.2.2 (was 4.2.5.2)
Using nio4r 2.3.1
Using websocket-extensions 0.1.3
Using websocket-driver 0.7.0
Using actioncable 5.2.2
Using globalid 0.4.1
Using activejob 5.2.2 (was 4.2.5.2)
Using mini_mime 1.0.1
Using mail 2.7.1
Using actionmailer 5.2.2 (was 4.2.5.2)
Using activemodel 5.2.2 (was 4.2.5.2)
Using arel 9.0.0 (was 6.0.4)
Using activerecord 5.2.2 (was 4.2.5.2)
Using mimemagic 0.3.3
Using marcel 0.3.3
Using activestorage 5.2.2
Using execjs 2.7.0
Using autoprefixer-rails 9.4.3
Using htmlentities 4.3.4
Using rubyzip 1.1.7
Using axlsx 2.1.0.pre
Using axlsx_rails 0.5.2
Using bcrypt 3.1.12
Using debug_inspector 0.0.3
Using binding_of_caller 0.8.0
Using rb-fsevent 0.10.3
Using ffi 1.9.25
Using rb-inotify 0.10.0
Using sass-listen 4.0.0
Using sass 3.7.2
Using bootstrap-sass 3.3.7
Using will_paginate 3.1.6
Using bootstrap-will_paginate 1.0.0
Using bundler 1.17.1
Using byebug 10.0.2
Using mime-types-data 3.2018.0812
Using mime-types 3.2.2
Using carrierwave 1.2.3
Using climate_control 0.2.0
Using coderay 1.1.2
Using coffee-script-source 1.12.2
Using coffee-script 2.4.1
Using method_source 0.9.2
Using thor 0.20.3
Using railties 5.2.2 (was 4.2.5.2)
Using coffee-rails 4.2.2 (was 4.1.1)
Using docile 1.3.1
Using faker 1.6.6
Using font-awesome-rails 4.7.0.4
Fetching temple 0.8.0
Installing temple 0.8.0
Using tilt 2.0.9
Fetching haml 5.0.4 (was 4.0.7)
Installing haml 5.0.4 (was 4.0.7)
Using multi_json 1.13.1
Using jbuilder 2.8.0
Using jquery-rails 4.3.3
Fetching jquery-ui-rails 6.0.1 (was 5.0.5)
Installing jquery-ui-rails 6.0.1 (was 5.0.5)
Using json 1.8.6
Fetching kaminari-core 1.1.1
Installing kaminari-core 1.1.1
Fetching kaminari-actionview 1.1.1
Installing kaminari-actionview 1.1.1
Fetching kaminari-activerecord 1.1.1
Installing kaminari-activerecord 1.1.1
Fetching kaminari 1.1.1 (was 0.17.0)
Installing kaminari 1.1.1 (was 0.17.0)
Using libv8 3.16.14.19 (x86_64-linux)
Using nested_form 0.3.2
Using request_store 1.4.1
Fetching paper_trail 10.1.0 (was 8.1.2)
Installing paper_trail 10.1.0 (was 8.1.2)
Using terrapin 0.6.0
Using paperclip 6.1.0
Using pg 0.18.4
Using pry 0.12.2
Using pry-rails 0.3.8
Fetching rack-pjax 1.0.0 (was 0.8.0)
Installing rack-pjax 1.0.0 (was 0.8.0)
Using sprockets 3.7.2
Using sprockets-rails 3.2.1
Using rails 5.2.2 (was 4.2.5.2)
Fetching rails-i18n 5.1.2 (was 4.0.9)
Installing rails-i18n 5.1.2 (was 4.0.9)
Using rails_serve_static_assets 0.0.5
Using rails_stdout_logging 0.0.5
Using rails_12factor 0.0.3
Using remotipart 1.4.2
Using sass-rails 5.0.7
Fetching rails_admin 1.4.2 (was 0.8.1)
Installing rails_admin 1.4.2 (was 0.8.1)
Using rdoc 4.3.0
Using ref 2.0.0
Using roo 2.7.1
Using ruby-ole 1.2.12.1
Using spreadsheet 1.1.8
Using roo-xls 1.2.0
Using sdoc 0.4.2
Using simplecov-html 0.10.2
Using simplecov 0.16.1
Using spring 2.0.2
Using therubyracer 0.12.3
Using turbolinks-source 5.2.0
Using turbolinks 5.2.0
Using uglifier 4.1.20
Using web-console 2.3.0
Bundle updated!
[email protected]:~/Desktop/se-CourseSelect$ rails -v
Rails 5.2.2
成功了!

修改后的Gemfile如下(改动的部分):

# gem 'rails', '4.2.5.2' 改动前
gem 'rails', '5.2.2' #wsy update for test
gem 'jquery-rails','~>4.3.3'
gem 'coffee-rails', '~> 4.2.2'
gem 'paper_trail','~>10.1.0'
#gem 'rails_admin', '~> 0.8.1' 改动前
gem 'rails_admin', '~> 1.4.2' #wsy updated for test
gem 'rails-i18n','~>5.1.2'

猜你喜欢

转载自blog.csdn.net/diyinqian/article/details/85227339

相关文章