execjs error when upgrade rails from 3.0.x to 3.1.0 [problem solved]

When I upgrade the rails from 3.0.x to 3.1.0, the old app can't work. Even the new one will give the error like:

/var/lib/gems/1.9.1/gems/execjs-1.2.9/lib/execjs/runtimes.rb:47:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
	from /var/lib/gems/1.9.1/gems/execjs-1.2.9/lib/execjs.rb:5:in `<module:ExecJS>'
	from /var/lib/gems/1.9.1/gems/execjs-1.2.9/lib/execjs.rb:4:in `<top (required)>'
	from /var/lib/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
	from /var/lib/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `<top (required)>'
	from /var/lib/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
	from /var/lib/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `<top (required)>'
	from /var/lib/gems/1.9.1/gems/coffee-rails-3.1.1/lib/coffee-rails.rb:1:in `require'
	from /var/lib/gems/1.9.1/gems/coffee-rails-3.1.1/lib/coffee-rails.rb:1:in `<top (required)>'
	from /var/lib/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
	from /var/lib/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
	from /var/lib/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
	from /var/lib/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `block in require'
	from /var/lib/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
	from /var/lib/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
	from /var/lib/gems/1.9.1/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
	from /media/ror/tmp2/config/application.rb:7:in `<top (required)>'
	from /var/lib/gems/1.9.1/gems/railties-3.1.0/lib/rails/commands.rb:52:in `require'
	from /var/lib/gems/1.9.1/gems/railties-3.1.0/lib/rails/commands.rb:52:in `block in <top (required)>'
	from /var/lib/gems/1.9.1/gems/railties-3.1.0/lib/rails/commands.rb:49:in `tap'
	from /var/lib/gems/1.9.1/gems/railties-3.1.0/lib/rails/commands.rb:49:in `<top (required)>'
	from script/rails:6:in `require'
	from script/rails:6:in `<main>'

To solve the problem, we need to do following steps:

sudo gem install execjs therubyracer

And add the following line in the Gemfile for the new RoR applications:

gem 'therubyracer'

In the 3.1.0, the default place for holding javascript is changed from 3.0.x. The old app can't find the right javascript under the new framework. Need to move the old js files to the new place.

Please refer to: http://stackoverflow.com/questions/6282307/rails-3-1-execjs-and-could-not-find-a-javascript-runtime


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值