#環境
OS | Rails Version |
---|---|
Ubuntu 12.04 | 3.2.9 |
#事象
$ bundle exec rails server
/home/kyamada/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
from /home/kyamada/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/execjs-1.4.0/lib/execjs.rb:5:in `<module:ExecJS>'
from /home/kyamada/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/execjs-1.4.0/lib/execjs.rb:4:in `<top (required)>'
from /home/kyamada/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
from /home/kyamada/.rbenv/versions/1.9.3-p194/
・・・
#解決策
NodeJsをインストール
$ sudo apt-get install nodejs
Gemfileに以下を追加
Gemfile
gem 'libv8'
gem 'execjs'
gem 'therubyracer', :platforms => :ruby
bundle installして、再実行
$ bundle install
$ bundle exec rails server
=> Booting WEBrick
=> Rails 3.2.9 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server