「Railsチュートリアルの各章が終わった状態を集めたリポジトリ」のテストが通るまで【Windows】
github.com ありがたや。 12章が終わったところから始めることにした。
ファイルを落してから最初のテストを実行できるまでに、いくつかエラーに遭遇したので、書き残しておきたい。
上記リンクのREDMEを参考に、以下を実行。
$ git clone https://github.com/yasslab/sample_apps.git
$ bundle install --without production
$ rails importmap:install turbo:install
ここまではREDMEの指示通り。
$ rails importmap:install turbo:install
を実行すると、最初のエラーが出るので、
TZInfo::DataSourceNotFound: tzinfo-data is not present. Please add gem 'tzinfo-data' to your Gemfile and run bundle install
Gemfileの一番下にある tzinfo-data gemのコメントアウトを外して、
# Windows ではタイムゾーン情報用の tzinfo-data gem を含める必要があります # gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
bundle installを実行。 これで先ほどの$ rails importmap:install turbo:installが通る。
続いてREDMEの指示に戻り、
$ rails db:migrate $ rails test
を実行。$ rails testをしようとすると、RAILS_ENV=testでやる必要があると言われるので
rails db:migrate RAILS_ENV=test
をしてから、もう一度 rails test を実行。すると、二つ目のエラーが…
UNIXServer is required (LoadError)
rubygems - Rails test error " UNIXServer is required (LoadError)" on windows - Stack Overflowを参考にして、test/test_helper.rbにある
# 指定のワーカー数でテストを並列実行する parallelize(workers: :number_of_processors)
parallelize(workers: :number_of_processors)をコメントアウトする。 そうすると、次のようなエラー内容に変わってくるので、
Minitest::UnexpectedError: ActionView::Template::Error: Permission denied @ rb_file_s_rename - (C:/Users/mntbl/RENGA/tmp/cache/assets/sprockets/v4.0.0/0C/0C_d9xA9xULAYq9l2TRdD9QCBHV0CxyxKhNAvGHLuAY.cache.27160.2716.527812, C:/Users/mntbl/RENGA/tmp/cache/assets/sprockets/v4.0.0/0C/0C_d9xA9xULAYq9l2TRdD9QCBHV0CxyxKhNAvGHLuAY.cache)
今度はRuby on Rails チュートリアル Windows での実施時の困ったメモ - Qiitaを参考に、
$ rails tmp:cache:clear $ rails assets:precompile
を実行。 これでrails testが通った!
そして、最終エラー
$ rails db:seed
からの
$ rails server
ERROR: worker mode not supported on ruby on this platform
config/puma.rbの中の
# workers ENV.fetch("WEB_CONCURRENCY") { 4 }
をコメントアウトすることで、一応解決。