error

-bash: wget: command not found

3-1-7Railsのエラーメッセージを日本語にする

$ wget https://raw.githubusercontent.com/svenfuchs/rails-i18n/master/rails/locale/ja.yml -P config/locales/
=> -bash: wget: command not found

wgetとはLinuxコマンドの1つであり、コマンドからDLする際に使われているが、Macではwgetはもともとインストールされていないので、 wgetコマンドをインストールする必要がある。

$ brew install wget

wgetをインストールし再度実行したところ解決。

Execjs::runtimeerror in tasks#index

3-3コントローラとビュー

resourcesメソッドでアクションに関するルーティングを一括設定し、localhost3000にアクセスしたときにタスクの一覧が表示されるようにする。

config/routes.rb
Rails.application.routes.draw do
  resources :tasks
  root to:'tasks#index'
end

ルーティングの設定を書き換え、bin/rails sを実行したところエラーになった。 調べたらExecjsはgemだということがわかり、Gemfileにgem 'execjs'を追加し、bundle installしても解決せず。また、 therubyracerをbundle installしてみたらエラーになった。 therubyracerはjavascriptの実行エンジンであるv8を使えるようにするgemであり、扱っているlibv8のバージョンが古いのと2017年にすでに終了していたのでインストールできなかった。

An error occurred while installing libv8 (3.16.14.19), and Bundler cannot continue.
Make sure that `gem install libv8 -v '3.16.14.19' --source 'https://rubygems.org/'` succeeds before bundling.

代わりに、therubyracerの後継であるmini_racerをbundle installしたら解決した。

f:id:meo2:20210324061051p:plain