カクカクしかじか...

ブラックSIer → 無給インターン → Railsエンジニアのブログ

専門学校時代に作ったRailsのバージョンが4.2.3のアプリを5.x.x系にあげていこうという話 vol.1

経緯

先日、メドピアさん主催の技術負債をテーマにした勉強会に参加し、稼働中のアプリのバージョンアップの大変さに関するお話を聞きました。 実際の仕事でも今まさにRails5系へのアップデートをおこなっていこうという機運が高まっている状態なので、自分も試しに過去に専門学校時代に作ったRails4系のアプリを5系にあげてみる事でそのツラミに向かい合おうと思ったのが今回の経緯です。 なお、気まぐれにまかせて不定期更新していくつもりなので、毎回の投稿で問題が解決しないところで終わる場合があります。
→ その場合は次の投稿までに解決を頑張るつもり!
* ローカル環境でバージョン上げて動作を確認することがとりあえずのゴールとする
* 途中で飽きたらやめるかも...

やっていく

DICという専門学校時代に作ったachieve というアプリを上げていく
ローカルのアプリを削除していたので、Github上のアプリを再び、cloneしてきた状態から開始
とりあえず、当時のままのGemfileの中身を確認する!

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# 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.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', 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 do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'
  gem 'letter_opener_web'
end

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
  gem 'pry-rails'
  gem 'better_errors'
  gem 'binding_of_caller'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  # Capistrano use gem
  gem 'capistrano', '3.6.0'
  gem 'capistrano-bundler'
  gem 'capistrano-rails'
  gem 'capistrano-rbenv'
  gem 'capistrano3-unicorn'
  # Rspec
  gem "rspec-rails"
  gem "factory_girl_rails"
end

group :test do
  gem "capybara"
  gem "database_cleaner"
  gem "launchy"
  gem "selenium-webdriver"
end

gem 'twitter-bootstrap-rails'
gem 'jquery-turbolinks'
gem 'rails_12factor', group: :production
gem 'devise'
gem 'faker'
gem 'dotenv-rails'
gem 'rails_admin'
gem 'cancan'
gem 'activeresource'
gem 'omniauth'
gem 'omniauth-twitter'
gem 'omniauth-facebook'
gem 'carrierwave'
gem 'mini_magick'
# プッシュ通知機能
gem 'pusher'
# 画像がS3に保存されるための設定
gem 'fog'
gem 'dotenv-rails'
gem 'unicorn'

bundle update をしていく

bundle updateの説明
→ bundle updateを実行するとBundlerはGemfileを元にgemのインストールを行い、Gemfile.lockが更新される

試しに gem 'rails', '4.2.3' の部分の 4.2.3部分を削除してbundle updateしてみる

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# 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.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', 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 do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'
  gem 'letter_opener_web'
end

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
  gem 'pry-rails'
  gem 'better_errors'
  gem 'binding_of_caller'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  # Capistrano use gem
  gem 'capistrano', '3.6.0'
  gem 'capistrano-bundler'
  gem 'capistrano-rails'
  gem 'capistrano-rbenv'
  gem 'capistrano3-unicorn'
  # Rspec
  gem "rspec-rails"
  gem "factory_girl_rails"
end

group :test do
  gem "capybara"
  gem "database_cleaner"
  gem "launchy"
  gem "selenium-webdriver"
end

gem 'twitter-bootstrap-rails'
gem 'jquery-turbolinks'
gem 'rails_12factor', group: :production
gem 'devise'
gem 'faker'
gem 'dotenv-rails'
gem 'rails_admin'
gem 'cancan'
gem 'activeresource'
gem 'omniauth'
gem 'omniauth-twitter'
gem 'omniauth-facebook'
gem 'carrierwave'
gem 'mini_magick'
# プッシュ通知機能
gem 'pusher'
# 画像がS3に保存されるための設定
gem 'fog'
gem 'dotenv-rails'
gem 'unicorn'
> bundle update
Your Gemfile lists the gem dotenv-rails (>= 0) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of one of them later.
Fetching gem metadata from https://rubygems.org/............
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies............................................................................................................................................................................................................................................................
Using rake 12.3.1 (was 12.0.0)
Using CFPropertyList 2.3.6 (was 2.3.5)
Using concurrent-ruby 1.0.5
Using i18n 1.1.0 (was 0.8.6)
Using minitest 5.11.3 (was 5.10.3)
Using thread_safe 0.3.6
Using tzinfo 1.2.5 (was 1.2.3)
Using activesupport 5.0.7 (was 4.2.3)
Using builder 3.2.3
Using erubis 2.7.0
Using mini_portile2 2.3.0 (was 2.2.0)
Using nokogiri 1.8.4 (was 1.8.0)
Using rails-dom-testing 2.0.3 (was 1.0.8)
Using crass 1.0.4
Using loofah 2.2.2 (was 2.0.3)
Using rails-html-sanitizer 1.0.4 (was 1.0.3)
Using actionview 5.0.7 (was 4.2.3)
Using rack 2.0.5 (was 1.6.8)
Using rack-test 0.6.3
Using actionpack 5.0.7 (was 4.2.3)
Using nio4r 2.3.1
Using websocket-extensions 0.1.3
Using websocket-driver 0.6.5
Using actioncable 5.0.7
Using globalid 0.4.1 (was 0.4.0)
Using activejob 5.0.7 (was 4.2.3)
Using mini_mime 1.0.1 (was 0.1.4)
Using mail 2.7.0 (was 2.6.6)
Using actionmailer 5.0.7 (was 4.2.3)
Using activemodel 5.0.7 (was 4.2.3)
Using activemodel-serializers-xml 1.0.2
Using arel 7.1.4 (was 6.0.4)
Using activerecord 5.0.7 (was 4.2.3)
Using activeresource 5.0.0 (was 4.1.0)
Using public_suffix 3.0.3 (was 2.0.5)
Using addressable 2.5.2 (was 2.5.1)
Using net-ssh 5.0.2 (was 4.1.0)
Using net-scp 1.2.1
Using sshkit 1.17.0 (was 1.14.0)
Using airbrussh 1.3.0
Using bcrypt 3.1.12 (was 3.1.11)
Using coderay 1.1.2 (was 1.1.1)
Using erubi 1.7.1 (was 1.6.1)
Using better_errors 2.5.0 (was 2.3.0)
Using debug_inspector 0.0.3
Using binding_of_caller 0.8.0 (was 0.7.2)
Using bundler 1.16.3
Using byebug 10.0.2 (was 9.1.0)
Using cancan 1.6.10
Using capistrano-harrow 0.5.3
Using capistrano 3.6.0
Using capistrano-bundler 1.3.0 (was 1.2.0)
Using capistrano-rails 1.4.0 (was 1.3.0)
Using capistrano-rbenv 2.1.4 (was 2.1.1)
Using capistrano3-unicorn 0.2.1
Using xpath 3.1.0 (was 2.1.0)
Using capybara 3.7.2 (was 2.15.1)
Using mime-types-data 3.2018.0812 (was 3.2016.0521)
Using mime-types 3.2.2 (was 3.1)
Using carrierwave 1.2.3 (was 1.1.0)
Using ffi 1.9.25 (was 1.9.18)
Using childprocess 0.9.0 (was 0.7.1)
Using coffee-script-source 1.12.2
Using execjs 2.7.0
Using coffee-script 2.4.1
Using method_source 0.9.0 (was 0.8.2)
Using thor 0.20.0
Using railties 5.0.7 (was 4.2.3)
Using coffee-rails 4.1.1
Using commonjs 0.2.7
Using database_cleaner 1.7.0 (was 1.6.1)
Using orm_adapter 0.5.0
Using responders 2.4.0
Using warden 1.2.7
Using devise 4.5.0 (was 4.3.0)
Using diff-lcs 1.3
Using dotenv 2.5.0 (was 2.2.1)
Using dotenv-rails 2.5.0 (was 2.2.1)
Using dry-inflector 0.1.2
Using excon 0.62.0 (was 0.58.0)
Using factory_girl 4.9.0 (was 4.8.0)
Using factory_girl_rails 4.9.0 (was 4.8.0)
Using faker 1.9.1 (was 1.8.4)
Using multipart-post 2.0.0
Using faraday 0.12.2
Using fission 0.5.0
Using formatador 0.2.5
Using fog-core 1.45.0
Using multi_json 1.13.1 (was 1.12.1)
Using fog-json 1.2.0 (was 1.0.2)
Using ipaddress 0.8.3
Using xml-simple 1.1.5
Using fog-aliyun 0.3.2 (was 0.2.0)
Using fog-xml 0.1.3
Using fog-atmos 0.1.0
Using fog-aws 2.0.1 (was 1.4.1)
Using fog-brightbox 0.16.1 (was 0.13.0)
Using fog-cloudatcost 0.1.2
Using fog-digitalocean 0.4.0 (was 0.3.0)
Using fog-dnsimple 1.0.0
Using fog-dynect 0.0.3
Using fog-ecloud 0.3.0
Using fog-google 0.1.0
Using fog-internet-archive 0.0.1
Using fog-joyent 0.0.1
Using fog-local 0.6.0 (was 0.3.1)
Using fog-openstack 0.2.4 (was 0.1.21)
Using fog-powerdns 0.2.0 (was 0.1.1)
Using fog-profitbricks 4.1.1 (was 4.0.0)
Using fog-rackspace 0.1.6 (was 0.1.5)
Using fog-radosgw 0.0.5
Using fog-riakcs 0.1.0
Using fog-sakuracloud 1.7.5
Using fog-serverlove 0.1.2
Using fog-softlayer 1.1.4
Using fog-storm_on_demand 0.1.1
Using fog-terremark 0.1.0
Using fog-vmfusion 0.1.0
Using fog-voxel 0.1.0
Using json 1.8.6
Using trollop 2.9.9 (was 2.1.2)
Using rbvmomi 1.13.0 (was 1.11.3)
Using fog-vsphere 2.3.0 (was 1.12.0)
Using fog-xenserver 0.3.0
Using fog 1.41.0
Using font-awesome-rails 4.7.0.4 (was 4.7.0.2)
Using temple 0.8.0
Using tilt 2.0.8
Using haml 5.0.4 (was 5.0.2)
Using hashie 3.5.7 (was 3.5.6)
Using httpclient 2.8.3
Using jbuilder 2.7.0
Using jquery-rails 4.3.3 (was 4.3.1)
Using turbolinks-source 5.2.0 (was 5.0.3)
Using turbolinks 5.2.0 (was 5.0.1)
Using jquery-turbolinks 2.1.0
Using jquery-ui-rails 6.0.1 (was 5.0.5)
Using jwt 1.5.6
Using kaminari-core 1.1.1 (was 1.0.1)
Using kaminari-actionview 1.1.1 (was 1.0.1)
Using kaminari-activerecord 1.1.1 (was 1.0.1)
Using kaminari 1.1.1 (was 1.0.1)
Using kgio 2.11.2 (was 2.11.0)
Using launchy 2.4.3
Using less 2.6.0
Using sprockets 3.7.2 (was 3.7.1)
Using less-rails 2.8.0
Using letter_opener 1.6.0 (was 1.4.1)
Using letter_opener_web 1.3.4 (was 1.3.1)
Using libv8 3.16.14.19 (x86_64-darwin-17)
Using mini_magick 4.8.0
Using multi_xml 0.6.0
Using nested_form 0.3.2
Using oauth 0.5.4 (was 0.5.3)
Using oauth2 1.4.0
Using omniauth 1.8.1 (was 1.6.1)
Using omniauth-oauth2 1.5.0 (was 1.4.0)
Using omniauth-facebook 5.0.0 (was 4.0.0)
Using omniauth-oauth 1.1.0
Using omniauth-twitter 1.4.0
Using pg 1.1.3 (was 0.21.0)
Using pry 0.11.3 (was 0.10.4)
Using pry-rails 0.3.6
Using pusher-signature 0.1.8
Using pusher 1.3.1
Using rack-pjax 1.0.0
Using sprockets-rails 3.2.1 (was 3.2.0)
Using rails 5.0.7 (was 4.2.3)
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 (was 1.3.1)
Using rb-fsevent 0.10.3 (was 0.10.2)
Using rb-inotify 0.9.10
Using sass-listen 4.0.0
Using sass 3.5.7 (was 3.5.1)
Using sass-rails 5.0.7 (was 5.0.6)
Using rails_admin 1.4.1 (was 1.2.0)
Using raindrops 0.19.0
Using rdoc 4.3.0
Using ref 2.0.0
Using rspec-support 3.8.0 (was 3.6.0)
Using rspec-core 3.8.0 (was 3.6.0)
Using rspec-expectations 3.8.1 (was 3.6.0)
Using rspec-mocks 3.8.0 (was 3.6.0)
Using rspec-rails 3.8.0 (was 3.6.1)
Using rubyzip 1.2.2 (was 1.2.1)
Using sdoc 0.4.2
Using selenium-webdriver 3.14.0 (was 3.5.2)
Using spring 2.0.2
Using therubyracer 0.12.3
Using twitter-bootstrap-rails 4.0.0 (was 3.2.2)
Using uglifier 4.1.19 (was 3.2.0)
Using unicorn 5.4.1 (was 5.3.0)
Using web-console 2.3.0
Bundle updated!

動作を確認してみる

取り急ぎRails 5.0.7 へアップデートされた模様

早速 bundle exec rails s してみる

gyazo.com

早速エラーが出たw

http://livedoor.blogimg.jp/sonisoku/imgs/4/f/4f82c8a4.gif

次回から直していく...

続く