我在文件夹'issues‘中创建了一个新的rails应用程序,当我想要'ruby s’时,我得到了一个错误。任何帮助都将不胜感激
[thiago@netbox issues]$ rails s
/home/thiago/.rvm/gems/ruby-1.9.3-p429/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/thiago/.rvm/gems/ruby-1.9.3-p429/gems/execjs-1.4.0/lib/execjs.rb:5:in `<module:ExecJS>'
from /home/thiago/.rvm/gems/ruby-1.9.3-p429/gems/execjs-1.4.0/lib/execjs.rb:4:in `<top (required)>'
from /home/thiago/.rvm/gems/ruby-1.9.3-p429/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
from /home/thiago/.rvm/gems/ruby-1.9.3-p429/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `<top (required)>'
from /home/thiago/.rvm/gems/ruby-1.9.3-p429/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
from /home/thiago/.rvm/gems/ruby-1.9.3-p429/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `<top (required)>'
from /home/thiago/.rvm/gems/ruby-1.9.3-p429/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `require'
from /home/thiago/.rvm/gems/ruby-1.9.3-p429/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `<top (required)>'
from /home/thiago/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from /home/thiago/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /home/thiago/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from /home/thiago/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from /home/thiago/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from /home/thiago/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from /home/thiago/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from /home/thiago/Documents/wdi/rails_practice/issues/config/application.rb:7:in `<top (required)>'
from /home/thiago/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.13/lib/rails/commands.rb:53:in `require'
from /home/thiago/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.13/lib/rails/commands.rb:53:in `block in <top (required)>'
from /home/thiago/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
from /home/thiago/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'我将'therubyracer‘gem添加到我的Gemfile中,然后'$包安装’就可以工作了!
Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.8'
gem 'sqlite3'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'therubyracer' # added发布于 2013-05-31 05:31:12
当我在一月份开始使用Rails时,我在Windows和Ubuntu上都遇到了同样的错误。错误非常简单。您需要一个JavaScript运行时环境才能启动服务器。
有许多解决方案可以解决这个问题。我在Ubuntu上使用的是安装NodeJS。
在Ubuntu上,你需要运行下面这样的命令来安装NodeJS:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get -y update
sudo apt-get -y install nodejs这些是我用来做这件事的命令,因为它将安装NodeJS的最新稳定版本,但是您可以只运行sudo apt-get -y install nodejs就可以了。
在Windows上,我使用的答案,可能还有其他的,是编辑你的Gemfile来安装therubyracer。我现在正在开发Rails4.0 RC1应用程序,它们都已经在Gemfile中添加了gem 'therubyracer', platform: :ruby,刚刚被注释掉了。
如果你在Windows上运行,你可以在你的Gemfile中添加gem 'therubyracer',我敢打赌,这会让你运行起来。然后运行bundle install。
发布于 2013-05-31 05:30:23
找不到JavaScript运行时。我假设你的Gemfile中没有这个。尝试编辑Gemfile并添加
gem 'therubyracer'然后运行
$ bundle install发布于 2013-05-31 05:31:18
你需要安装一个javascript解释器:
将此代码添加到Gemfile中:
gem "libv8", ">= 3.11.8"
gem "therubyracer", ">= 0.11.0", :group => :assets, :platform => :ruby, :require => "v8"此外,您还可以检查其他选项,如用于生产的Node.js,但对于开发,这将是足够的。
https://stackoverflow.com/questions/16846088
复制相似问题