环境:linux操作系统, ruby1.9.3+rails3.2
?
如果出现下面问题:
however, when i try to activate the server with 'rails s' or 'rails server' , I still get: /usr/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs/runtimes.rb:50:in `autodetect': Could not fi
nd a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtime
s. (ExecJS::RuntimeUnavailable)
from /usr/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs.rb:5:in `<module:ExecJS>'
from /usr/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs.rb:4:in `<top (required)>'
from /usr/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
from /usr/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `<top (re
quired)>'
from /usr/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
from /usr/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `<top (re
quired)>'
from /usr/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.1/lib/coffee-rails.rb:1:in `require'
from /usr/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.1/lib/coffee-rails.rb:1:in `<top (requ
ired)>'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 l
evels) in require'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in r
equire'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
from /home/john/rails_space/config/application.rb:7:in `<top (required)>'
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.0/lib/rails/commands.rb:53:in `require'
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.0/lib/rails/commands.rb:53:in `block in <t
op (required)>'
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.0/lib/rails/commands.rb:50:in `tap'
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.0/lib/rails/commands.rb:50:in `<top (requi
red)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
?
?
?
解决办法:
gemfile文件中添加如下两句代码:
gem 'execjs'
gem 'therubyracer'
?
运行:
bundle install
?