Rails 4.1.4中的ExecJS :: RuntimeUnavailable

时间:2014-07-07 11:49:48

标签: javascript ruby-on-rails ruby windows execjs

更新:事情正在发挥作用!

感谢deep,我安装了node.js,然后通过添加gem 'tzinfo-data', platforms: [:mingw, :mswin]bundle update得到了解决的TZInfo :: DataSourceNotFound错误。

先生,谢谢你!


首先,我是一个完全初学者的轨道(只是为了让你得到我的初学者:我觉得自己只是在这里张贴的专家)这是我的第一个问题,所以请原谅我,如果我'我不太清楚。

所以,我是一名Windows 7用户,使用One Month课程学习rails,我在尝试时遇到错误:

$ rake routes
rake aborted!
ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://git
hub.com/sstephenson/execjs for a list of available runtimes.
c:/Users/Marc Montagne/Desktop/pinteresting/config/application.rb:7:in `<top (re
quired)>'
c:/Users/Marc Montagne/Desktop/pinteresting/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

$ rails server
c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/execjs-2.0.2/lib/execjs/run
times.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://gi
thub.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUn
available)
        from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/execjs-2.0.2/l
ib/execjs.rb:5:in `<module:ExecJS>'
        from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/execjs-2.0.2/l
ib/execjs.rb:4:in `<top (required)>'
        from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/uglifier-2.4.0
/lib/uglifier.rb:3:in `require'
        from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/uglifier-2.4.0
/lib/uglifier.rb:3:in `<top (required)>'
        from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler/runtime.rb:72:in `require'
        from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler/runtime.rb:72:in `block (2 levels) in require'
        from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler/runtime.rb:70:in `each'
        from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler/runtime.rb:70:in `block in require'
        from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler/runtime.rb:59:in `each'
        from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler/runtime.rb:59:in `require'
        from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/
lib/bundler.rb:132:in `require'
        from c:/Users/Marc Montagne/Desktop/pinteresting/config/application.rb:7
:in `<top (required)>'
        from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.4
/lib/rails/commands/commands_tasks.rb:79:in `require'
        from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.4
/lib/rails/commands/commands_tasks.rb:79:in `block in server'
        from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.4
/lib/rails/commands/commands_tasks.rb:76:in `tap'
        from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.4
/lib/rails/commands/commands_tasks.rb:76:in `server'
        from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.4
/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
        from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.4
/lib/rails/commands.rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

我理解的只是我有一个ExecJS问题。作为初学者,我甚至不知道ExecJS是什么。

我读了很棒的帖子#12520456,虽然编辑runtimes.rb并没有解决我的问题,但它仍然让我更好地了解情况,并通过修复问题而不是“忽略”解决问题的意愿它“通过添加node.js,特别是考虑到我之前可以运行我的服务器并且我想解决我基本上已经破坏的事实。

我的意思是,我认为在编辑我的Windows环境的PATH(我甚至不知道这是什么)时我做错了什么来解决我在安装Heroku时遇到的问题。我记得当我在某处阅读时编辑该部分,虽然它似乎修复了我的Heroku问题,但我觉得它搞砸了其余部分。

提前感谢您的帮助和理解。

4 个答案:

答案 0 :(得分:10)

Ubuntu用户

我在Ubuntu 11.04上遇到了类似的问题。安装Node.js修复了它。

从Ubuntu 13.04 x64开始,你只需要运行:

sudo apt-get install nodejs

这将解决问题。 CentOS / RedHat用户

sudo yum install nodejs

答案 1 :(得分:4)

快速简便的解决方案是在Gemfile中取消注释此行并再次运行bundle install

gem 'therubyracer',  platforms: :ruby

答案 2 :(得分:1)

@KevinP here详细解答了这个问题。

按照上面的链接,您需要进入Execjs的runtimes.rb并更改其答案中指定的那一行。之后,重新启动服务器,它应该开始工作。

需要更改的块如下所示:

JScript = ExternalRuntime.new(
  :name        => "JScript",
  :command     => "cscript //E:jscript //Nologo",
  :runner_path => ExecJS.root + "/support/jscript_runner.js",
  :encoding    => 'UTF-8' # CScript with //U returns UTF-16LE
)

^归功于Kevin P

几天后我也回答了这个问题。 https://stackoverflow.com/a/24591983/2456549

答案 3 :(得分:0)

基于@RedDeath答案,这是面向Alpine用户的方法:

apk add nodejs

那为我解决了错误。