0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

4ヶ月振りにポートフォリオに触ったらRSpecとHerokuのデプロイでエラーが出た話

Last updated at Posted at 2019-07-06

はじめに

エンジニアとして働き始めて早くも4ヶ月経ちました。

7月に入ってから業務でデータ分析基盤の構築に携わることになり、Fluentd、Embulk、ElasticSearch等を勉強する必要性が出てきたため、それらを勉強するための実験場として転職活動時に作成したポートフォリオを利用しようと思い、4ヶ月振りに触ったのですが、webdriverとHerokuでガッツリはまってしまったので誰かの参考になればと思い、久々に記事を書くことにしました。

前提

  • macOS Mojave
  • Ruby 2.5.0
  • Rails 5.2.2

要点

RSpecでのエラー

何点かファイルを変更したのでテストを走らせたらフィーチャースペックで見事に全コケしてて、何事だろうと思ってエラー内容を確認したところ、下記のようなエラーでした。

Selenium::WebDriver::Error::SessionNotCreatedError:
session not created: Chrome version must be between 70 and 73

Chromeのバージョンが70~73の間に入ってないぞという話なので、使用しているChromeのバージョンを調べたところ、75.0.3770.100とのことだったので、これが原因と分かりました。

image.png

更に調べていくと、chromedriver-helper gemは廃止予定らしく、webdrivers gemを使えば良いとのことだったので、一旦Gemfile.lockを削除してbundle installを実行した後、再度テストをするとテストが通るようになりました。
(ちなみに、この時はこのGemfile.lockを作り直す作業が、後述するHerokuエラーに繋がることなど知る由もありませんでした。)

Gemfile
-   gem 'chromedriver-helper'
+   gem 'webdrivers', '~> 3.0'

Herokuデプロイでのエラー

テストが通ったので最後にデプロイして終わりだーと思ったのですが、またしてもここでエラーに見舞われました。
エラーの内容は下記の通りです。

remote:        Activating bundler (2.0.2) failed:
remote:        Could not find 'bundler' (2.0.2) required by your /tmp/build_be01b72423bcb8427f9483fee7b4337e/Gemfile.lock.
remote:        To update to the latest version installed on your system, run `bundle update --bundler`.
remote:        To install the missing version, run `gem install bundler:2.0.2`
remote:        Checked in 'GEM_PATH=vendor/bundle/ruby/2.5.0', execute `gem env` for more information
remote:
remote:        To install the version of bundler this project requires, run `gem install bundler -v '2.0.2'`
remote:
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to tranquil-ravine-25204.

何やらActivating bundler (2.0.2) failedとのことで、gem install bundlerが上手くいかないとのことです。

以前動いていた時のbundlerのバージョンは何だったっけと思い、自分のポートフォリオの過去のブランチ中にあるGemfile.lockの最後の行を見ると、

BUNDLED WITH
   2.0.1

となっていたので、再度Gemfile.lockを削除してbundle _2.0.1_ installを実行して、herokuへのデプロイをしてみると解決しました。

ちなみに、調べてみたところ何やらbundler2.0.2はつい先月リリースされたものらしく、その辺が影響しているっぽいです。

image.png

(おまけ)その他

Faker gemも更新されていたようで、seedデータを入れようとしたら「Faker::OnePieceなんて知らないよ」と怒られました。
公式ドキュメントを見たらFaker::JapaneseMedia::OnePieceとする必要があるとのことが分かったので修正したら解決しました。

まとめ

当たり前のことですが、たった4ヶ月でもソフトウェアは進化しているのだなぁと改めて感じた体験でした💡
この記事で同じミスで時間を奪われる人が減れば幸いです。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?