はじめに
Ruby をアップデートすると Segmentation fault する現象が変わりません。とりあえず、2.2.2 でいける Rails 5.2 まではこのまま進めてしまおうと思います。
Rails のアップデート
まず、Gemfile の rails を5.1 の最終である 5.1.7 に変更します。
gem 'rails', '5.1.7'
bundle update します。
bundle update
app:update 時に include でエラーが出るのは custom で作った rake task で activerecord 関係を include していたからでした。しばらくこれらを使わないので、コメントアウトしておきます。
env THOR_DIFF=vimdiff bin/rake app:update
Devise のヘルパの変更
以下の DEPRECATION WARNING が出ていました。Devise::TestHelpers を全て Devise::Test::ControllerHelpers に変更しました。
DEPRECATION WARNING: [Devise] including `Devise::TestHelpers` is deprecated and will be removed from Devise. For controller tests, please include `Devise::Test::ControllerHelpers` instead.
Guard gem の修正
be guard を実行したら、以下のエラーエラーができるようになってしまいました。探したところ、Current version of Guard crashing with nil:Nilclass · Issue #937 · guard/guard · GitHubという記事を見つけました。2.16.1 以上にすればよいとあります。
in `stop': undefined method `stop' for nil:NilClass (NoMethodError)
これまで 2.16 未満に設定していたのですが、リミッタを外しました。ただ、Ruby 2.2.2 だとguard-2.16.2/lib/guard/commander.rbの以下の部分でエラーになりました。
def stop listener.&.stop interactor.&.background
Ruby 2.2.2 ではまだ使えない「&.」を使ってしまっています。とりあえず以前の形式に変更したところ、無事に動きました。Guard の Ruby の制約がまずいんですね。どうせ後で Ruby のバージョンは上げるので、とりあえず動けばいいです。
def stop listener && listener.stop interactor && interactor.background
form_forとform_tagのform_withへの統合
Rails 5.1 から form_with が導入されています。後で修正するつもりですが、まだ form_for や form_tag が使えなくなるわけでないので、とりあえず放置します。いよいよ使えなくなったら対応することにします。
Rails 5.1より前のHTMLフォーム生成メソッドは、モデルインスタンス用のform_forと、カスタムURL用のform_tagの2種類がありました。
Rails 5.1ではこの2つのインターフェイスをform_withに統合し、URLベース、スコープ、モデルを指定してformタグを生成できるようになりました。
おわりに
5.0 での対応に比べると特に大きな変更はありませんでした。form_with をやるとなると大変ですが、先延ばしにします。
Finished in 12 minutes 17 seconds (files took 7.57 seconds to load) 7726 examples, 0 failures, 98 pending
gem の推移はこんな感じです。Ruby の Segmentation fault の問題の切り分けのために、いろいろと Gemfile から使ってなさそうなものをコメントしたので、かなり減っています。後で問題がなさそうなら内容を確認して復活させようと思います。
(12/29追記) Segmentation fault の原因が hpricot だとわかったので、 Ruby 2.5.1 でやり直してみました。こちらも少し速くなったくらいでしょうか。
Finished in 11 minutes 51 seconds (files took 5.19 seconds to load) 7726 examples, 0 failures, 98 pending
| gem_name | ver5.0 | ver5.1 | changed |
|---|---|---|---|
| actioncable | 5.0.7.2 | 5.1.7 | ↑ |
| actionmailer | 5.0.7.2 | 5.1.7 | ↑ |
| actionpack | 5.0.7.2 | 5.1.7 | ↑ |
| actionview | 5.0.7.2 | 5.1.7 | ↑ |
| activejob | 5.0.7.2 | 5.1.7 | ↑ |
| activemodel | 5.0.7.2 | 5.1.7 | ↑ |
| activerecord | 5.0.7.2 | 5.1.7 | ↑ |
| activesupport | 5.0.7.2 | 5.1.7 | ↑ |
| arel | 7.1.4 | 8.0.0 | ↑ |
| bcrypt | 3.1.16 | 3.1.16 | = |
| better_errors | 2.9.1 | - | |
| binding_of_caller | 0.8.0 | 0.8.1 | ↑ |
| brakeman | 4.4.0 | - | |
| builder | 3.2.4 | 3.2.4 | = |
| choice | 0.2.0 | 0.2.0 | = |
| ci_reporter | 2.0.0 | - | |
| coderay | 1.1.3 | 1.1.3 | = |
| coffee-rails | 4.2.2 | 4.2.2 | = |
| coffee-script | 2.4.1 | 2.4.1 | = |
| coffee-script-source | 1.12.2 | 1.12.2 | = |
| concurrent-ruby | 1.1.7 | 1.1.7 | = |
| crass | 1.0.6 | 1.0.6 | = |
| database_cleaner | 1.8.5 | 1.8.5 | = |
| debug_inspector | 0.0.3 | - | |
| devise | 4.0.0.rc2 | 4.7.3 | ↑ |
| devise-encryptable | 0.2.0 | 0.2.0 | = |
| devise_ldap_authenticatable | 0.8.7 | 0.8.7 | = |
| diff-lcs | 1.4.4 | 1.4.4 | = |
| docile | 1.3.4 | 1.3.4 | = |
| dotenv | 2.7.6 | 2.7.6 | = |
| erubi | 1.10.0 | 1.10.0 | = |
| erubis | 2.7.0 | 2.7.0 | = |
| execjs | 2.7.0 | 2.7.0 | = |
| factory_bot | 4.11.1 | 4.11.1 | = |
| factory_bot_rails | 4.11.1 | 4.11.1 | = |
| ffi | 1.12.2 | 1.12.2 | = |
| formatador | 0.2.5 | 0.2.5 | = |
| globalid | 0.4.2 | 0.4.2 | = |
| guard | 2.15.1 | 2.16.2 | ↑ |
| guard-compat | 1.2.1 | 1.2.1 | = |
| guard-rspec | 4.7.3 | 4.7.3 | = |
| haml | 4.0.7 | 5.2.1 | ↑ |
| haml-rails | 1.0.0 | 1.0.0 | = |
| hpricot | 0.8.6 | 0.8.6 | = |
| html2haml | 2.2.0 | 2.2.0 | = |
| i18n | 1.5.1 | 1.5.1 | = |
| interception | 0.5 | - | |
| jquery-rails | 4.4.0 | 4.4.0 | = |
| json | 2.5.1 | 2.5.1 | = |
| kaminari | 1.2.1 | 1.2.1 | = |
| kaminari-actionview | 1.2.1 | 1.2.1 | = |
| kaminari-activerecord | 1.2.1 | 1.2.1 | = |
| kaminari-core | 1.2.1 | 1.2.1 | = |
| listen | 3.0.8 | 3.0.8 | = |
| loofah | 2.8.0 | 2.8.0 | = |
| lumberjack | 1.0.13 | 1.0.13 | = |
| 2.7.1 | 2.7.1 | = | |
| method_source | 0.9.2 | 1.0.0 | ↑ |
| mini_mime | 1.0.2 | 1.0.2 | = |
| mini_portile2 | 2.4.0 | 2.4.0 | = |
| minitest | 5.14.2 | 5.14.2 | = |
| nenv | 0.3.0 | 0.3.0 | = |
| net-ldap | 0.17.0 | 0.17.0 | = |
| nio4r | 2.3.1 | 2.3.1 | = |
| nokogiri | 1.9.1 | 1.9.1 | = |
| notiffany | 0.1.3 | 0.1.3 | = |
| orm_adapter | 0.5.0 | 0.5.0 | = |
| pg | 0.20.0 | 1.2.3 | ↑ |
| power_assert | 1.2.0 | 1.2.0 | = |
| pry | 0.12.2 | 0.13.1 | ↑ |
| pry-doc | 1.1.0 | - | |
| pry-rails | 0.3.9 | - | |
| pry-rescue | 1.5.2 | - | |
| public_suffix | 3.1.1 | - | |
| puma | 5.1.1 | 5.1.1 | = |
| rack | 2.1.4 | 2.1.4 | = |
| rack-cache | 1.9.0 | 1.9.0 | = |
| rack-test | 0.6.3 | 1.1.0 | ↑ |
| rails | 5.0.7.2 | 5.1.7 | ↑ |
| rails-controller-testing | 1.0.5 | 1.0.5 | = |
| rails-dom-testing | 2.0.3 | 2.0.3 | = |
| rails-erd | 1.6.0 | 1.6.0 | = |
| rails-html-sanitizer | 1.3.0 | 1.3.0 | = |
| railties | 5.0.7.2 | 5.1.7 | ↑ |
| rake | 13.0.3 | 13.0.3 | = |
| rb-fsevent | 0.10.4 | 0.10.4 | = |
| rb-inotify | 0.10.1 | 0.10.1 | = |
| rb-readline | 0.5.5 | - | |
| rdoc | 6.2.0 | 6.2.0 | = |
| redcarpet | 3.5.1 | 3.5.1 | = |
| responders | 2.4.1 | 2.4.1 | = |
| rspec | 3.10.0 | 3.10.0 | = |
| rspec-core | 3.10.0 | 3.10.1 | ↑ |
| rspec-expectations | 3.10.0 | 3.10.1 | ↑ |
| rspec-mocks | 3.10.0 | 3.10.0 | = |
| rspec-rails | 4.0.1 | 4.0.2 | ↑ |
| rspec-support | 3.10.0 | 3.10.1 | ↑ |
| ruby-graphviz | 1.2.4 | 1.2.4 | = |
| ruby_parser | 3.15.0 | 3.15.0 | = |
| sass | 3.7.4 | - | |
| sass-listen | 4.0.0 | - | |
| sass-rails | 6.0.0 | - | |
| sassc | 2.4.0 | 2.4.0 | = |
| sassc-rails | 2.1.2 | 2.1.2 | = |
| sexp_processor | 4.15.1 | 4.15.1 | = |
| shellany | 0.0.1 | 0.0.1 | = |
| simplecov | 0.17.1 | 0.17.1 | = |
| simplecov-html | 0.10.2 | 0.10.2 | = |
| simplecov-rcov | 0.2.3 | 0.2.3 | = |
| spring | 2.0.2 | 2.0.2 | = |
| spring-commands-rspec | 1.0.4 | 1.0.4 | = |
| spring-watcher-listen | 2.0.1 | + | |
| sprockets | 3.7.2 | 3.7.2 | = |
| sprockets-rails | 3.2.2 | 3.2.2 | = |
| temple | 0.8.2 | + | |
| test-unit | 3.3.8 | 3.3.8 | = |
| thor | 0.20.3 | 1.0.1 | ↑ |
| thread_safe | 0.3.6 | 0.3.6 | = |
| tilt | 2.0.10 | 2.0.10 | = |
| tzinfo | 1.2.9 | 1.2.9 | = |
| uglifier | 4.2.0 | 4.2.0 | = |
| uniform_notifier | 1.11.0 | - | |
| warden | 1.2.9 | 1.2.9 | = |
| web-console | 2.3.0 | 3.7.0 | ↑ |
| websocket-driver | 0.6.5 | 0.6.5 | = |
| websocket-extensions | 0.1.5 | 0.1.5 | = |
| yard | 0.9.25 | 0.9.26 | ↑ |
| yard-activerecord | 0.0.16 | 0.0.16 | = |