# zoshoin-db-zosan 20190815 作業メモ ## Rails が起動しない件 ``` rails s -p $PORT -b $IP ``` で 下記のエラーが出て Rails が起動できない。 ``` Array values in the parameter to `Gem.paths=` are deprecated. Please use a String or nil. An Array ({"GEM_PATH"=>["/home/ubuntu/.rvm/gems/ruby-2.6.3", "/home/ubuntu/.rvm/rubies/ruby-2.6.3/lib/ruby/gems/2.6.0"]}) was passed in from bin/rails:3:in `load' Your Ruby version is 2.6.3, but your Gemfile specified 2.4.5 ``` 調べてみると、spring の問題のようでアップデートすると解消するらしい。 ``` bundle update spring && bundle exec spring binstub --remove --all && bundle exec spring binstub --all ``` を実行すると、 ``` Your Ruby version is 2.6.3, but your Gemfile specified 2.4.5 ``` と言われる。 画面の指示どおりに `rvm install "ruby-2.4.5-p335"` とすると、 `No binary rubies available for: ubuntu/18.04/x86_64/ruby-2.4.5-p335.` と言われるが、 `rvm install "ruby-2.4.5` ではインストールできた。 `bundle update spring` を再実行すると、今度は `pg` にエラーが発生したが、PostgreSQL と関連ライブラリをインストールすると解消するらしいので、 ``` sudo apt install postgresql ``` を実行した。 参考 URL: https://qiita.com/oke-py/items/75333cf564480d062006 今度は `Can't find the 'libpq-fe.h header when trying to install pg gem` と出たので、 ``` sudo apt install libpq-dev ``` として再トライしたところ、正常に完了した。 参考URL: https://stackoverflow.com/questions/6040583/cant-find-the-libpq-fe-h-header-when-trying-to-install-pg-gem これで、 ``` rails s -p $PORT -b $IP ``` で正常に Rails が起動するようになった。 ## セキュリティ警告が出た gem の更新 - bootstrap-sass - nokogiri `bundle update bootstrap-sass` `bundle update nokogiri` 途中で `rmagick` 関連のエラーが出たので、 `sudo apt install libmagickwand-dev imagemagick` してから再度実行したところ、正常に終了した。 参考URL: https://stackoverflow.com/a/16775397/8778462 ## heroku デプロイ 以上を経て git にコミット、`git push heroku master` で正常に起動できた。