在“rails s”中获取错误,服务器未运行

时间:2011-10-07 12:13:57

标签: ruby-on-rails ruby ruby-on-rails-3.1

这是Rails 3.1.0

我做了什么:

rails new site
cd site
rails s

我收到的消息:

/home/user1/.rvm/gems/ruby-1.9.2-p180/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 /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/execjs-1.2.9/lib/execjs.rb:5:in `<module:ExecJS>'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/execjs-1.2.9/lib/execjs.rb:4:in `<top (required)>'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `<top (required)>'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `<top (required)>'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/coffee-rails-3.1.1/lib/coffee-rails.rb:1:in `require'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/coffee-rails-3.1.1/lib/coffee-rails.rb:1:in `<top (required)>'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
    from /home/user1/social/config/application.rb:7:in `<top (required)>'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0/lib/rails/commands.rb:52:in `require'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0/lib/rails/commands.rb:52:in `block in <top (required)>'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0/lib/rails/commands.rb:49:in `tap'
    from /home/user1/.rvm/gems/ruby-1.9.2-p180/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>'

为什么我收到此错误?

任何人都可以提示修复它吗?

5 个答案:

答案 0 :(得分:3)

如错误提到,您没有安装Javascript运行时。你应该自己选择一个。

将此添加到您的Gemfile:

gem "therubyracer"

然后运行bundle install并重试。

答案 1 :(得分:3)

您可能还需要安装node.js(对我有帮助)

答案 2 :(得分:2)

$sudo apt-get install nodejs

为我工作......

答案 3 :(得分:1)

只需打开应用程序文件夹根目录下的“Gemfile”文件,然后将以下行粘贴在那里。

gem 'execjs'

gem 'libv8'

gem 'therubyracer'

粘贴后,只需保存文件并在命令提示符下执行'bundle update'。

成功完成捆绑更新后,您尝试运行'rails s'。它有效!!

谢谢。

答案 4 :(得分:0)

通过查看您的问题,您的系统会抱怨lack of JavaScript runtime.

您应该访问https://github.com/sstephenson/execjs以获取可能性列表。

我建议你从这个http://nodejs.org/下载node.js.

按照这种方式:

cd *your download dir*
tar xvf node-v0.4.11.tar.gz
cd node-v0.4.11
./configure
make
sudo make install

我给出了这个答案,因为这对我有用。

这个答案对你有帮助。