为什么在Gemfile中缺省将gem`therubyracer注释掉? [英] Why is the gem `therubyracer` commented out by default in Gemfile?

查看:152
本文介绍了为什么在Gemfile中缺省将gem`therubyracer注释掉?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个rails应用程序,并尝试启动rails服务器。我得到以下错误:

  /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/execjs -2.0.1 / lib / execjs / runtimes.rb:51:在`autodetect'中:找不到JavaScript运行时。有关可用运行时的列表,请参阅https://github.com/sstephenson/execjs。 (ExecJS :: RuntimeUnavailable)
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/execjs-2.0.1/lib/execjs.rb:5:in`< module :ExecJS>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/execjs-2.0.1/lib/execjs.rb:4:in`< top(必填项)>'从/home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/uglifier-2.2.1/lib/uglifier.rb:3:in'require'

$ b from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/uglifier-2.2.1/lib/uglifier.rb:3:in`< top(required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in`require'
from / home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:在`block(2 levels)in require'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in`each'
from / home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:在'block in require'中从/ home开始
/ritesh/.rvm/gems/ruby -1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:来自/home/ritesh/.rvm/gems/ruby-1.9的`each'
。 3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:在'require'中
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429 @ global / gems / bundler-1.3.5 / lib / bundler.rb:132:在'require'
从/home/ritesh/projects/interview/config/application.rb:7:in`< top (required)>'from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/railties-4.0.0/lib/rails/commands.rb:76:in`require中的
'来自/home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/railties-4.0.0/lib/rails/commands.rb:76:in的
< top< top(必需)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/railties-4.0.0/lib/rails/commands.rb:73:in`tap'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/railties-4.0.0/lib/rails/commands.rb:73:in`< top(required)> ;'bin / rails中的
:4中的'require'
从bin / rails:4:在< main>中

尽管我可以通过在 gem'therubyracer'平台之前删除注释来修复它,platform::ruby from Gemfile p>

为什么当启动rails应用程序时,我们需要它的时候,这个gem注释掉了? 解决方案因为如果在机器上安装了另一个JavaScript运行库(比如Node.js),Rails可以使用它,而不需要使用therubyracer。



Rails使用ExecJS来加载JavaScript运行时。有关ExecJS的更多信息,请参阅其Github页面: https://github.com/sstephenson/execjs 。自述文件提供了可用运行时的列表(作为错误日志记录)。

根据您的部署过程和生产环境,您的JavaScript运行时间可能无关紧要使用。有些人对therubyracer库的大小有问题(请参阅 Rails - 找不到一个JavaScript运行时?),并且将它安装到生产服务器上可能不太明智。

I created a rails application, and tried to start the rails server. I got following error:

/home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/execjs-2.0.1/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/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/execjs-2.0.1/lib/execjs.rb:5:in `<module:ExecJS>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/execjs-2.0.1/lib/execjs.rb:4:in `<top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/uglifier-2.2.1/lib/uglifier.rb:3:in `require'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/uglifier-2.2.1/lib/uglifier.rb:3:in `<top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from /home/ritesh/.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/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from /home/ritesh/projects/interview/config/application.rb:7:in `<top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/railties-4.0.0/lib/rails/commands.rb:76:in `require'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/railties-4.0.0/lib/rails/commands.rb:76:in `block in <top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

although I was able to fix it by removing the comment before the line gem 'therubyracer', platforms: :ruby from Gemfile.

Why is this gem commented out when we require it at very first place when starting rails application?

解决方案

Because if another JavaScript runtime (like Node.js) is installed on the machine, Rails can use that, and therubyracer is not required.

Rails uses ExecJS to load a JavaScript runtime. For more information on ExecJS, see its Github page: https://github.com/sstephenson/execjs. The readme provides a list of usable runtimes (as your error log notes).

Depending on your deployment process and your production environment, it may not really matter which JavaScript runtime you use. Some people have issues with the size of the therubyracer library (see Rails - Could not find a JavaScript runtime?), and it may not be smart to install it on your production server.

这篇关于为什么在Gemfile中缺省将gem`therubyracer注释掉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆