Rails3.2で Could not find a JavaScript runtime エラー発生対応メモ

環境を変える前は特にエラー無かったなと思ったのですが、どうやら Node.js がインストールされているとそちらを利用するそうです。

今回は Node.js をインストールする予定はないので、 gem で対応します。

環境

  • OS: Ubuntu 12.04 64bit
  • Ruby on Rails 3.2.6
  • Gem
    • execjs 1.4.0
    • therubyracer 0.10.1

rake を実行したらエラー

ちなみに rails s を実行でも同じエラーが出ました。

Terminal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
$ rake db:create --trace
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@hoge_rails3/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@hoge_rails3/gems/execjs-1.4.0/lib/execjs.rb:5
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@hoge_rails3/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@hoge_rails3/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@hoge_rails3/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@hoge_rails3/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@hoge_rails3/gems/coffee-script-2.2.0/lib/coffee_script.rb:1
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@hoge_rails3/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@hoge_rails3/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@hoge_rails3/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@hoge_rails3/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@hoge_rails3/gems/coffee-script-2.2.0/lib/coffee-script.rb:1
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@hoge_rails3/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@hoge_rails3/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@hoge_rails3/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@hoge_rails3/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@hoge_rails3/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:68:in `require'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:68:in `require'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:66:in `each'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:66:in `require'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:55:in `each'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:55:in `require'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@global/gems/bundler-1.1.4/lib/bundler.rb:119:in `require'
/home/nanigashi/workspace/hoge/branches/hoge/config/application.rb:7
/home/nanigashi/workspace/hoge/branches/hoge/Rakefile:5:in `require'
/home/nanigashi/workspace/hoge/branches/hoge/Rakefile:5
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@global/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@global/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@global/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@global/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `load_rakefile'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@global/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@global/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `run'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@global/gems/rake-0.9.2.2/bin/rake:33
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@global/bin/rake:19:in `load'
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@global/bin/rake:19
/home/nanigashi/.rvm/gems/ruby-1.8.7-p358@global/bin/ruby_noexec_wrapper:14

javascriptの生成エンジンをインストール

javascriptの生成エンジンが無いためエラーになってるようなのでインストールします。

node.js でも問題ないようですが、利用する予定はないので今回はgemで対応します。

Gemfile に以下を記述します。

Gemfile
1
2
gem 'execjs'
gem 'therubyracer'

bundle install を実行すれば大丈夫です。

以上です。

© 2018 磁力式駆動 All Rights Reserved.
Theme by hiero