找不到 JavaScript 运行时。有关可用运行时的列表,请参阅 https://github.com/sstephenson/execjs。(ExecJS::RuntimeUnavailable)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8059332/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 04:34:01  来源:igfitidea点击:

Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

javascriptruby-on-railsruby-on-rails-3.1v8dreamhost

提问by Rich

My website has been broken since Dreamhost upgraded their servers a couple of weeks ago. I have been tearing my hair out trying to get it fixed and made some progress but am stuck on what is hopefully the final issue.

自从 Dreamhost 几周前升级了他们的服务器后,我的网站就被破坏了。我一直在努力修复它并取得了一些进展,但我一直在努力解决最后的问题。

I'm using Rails 3.1.1 on Ruby 1.8.7 and get presented with a 'Ruby (Rack) application could not be started error' from PhusionPassenger. It states that it 'Could not find a JavaScript runtime. See https://github.com/sstephenson/execjsfor a list of available runtimes. (ExecJS::RuntimeUnavailable)'. Searching for this on Dreamhost's wiki has suggested a solution to install 'therubyracer' gem.

我在 Ruby 1.8.7 上使用 Rails 3.1.1 并收到来自 PhusionPassenger 的“Ruby (Rack) 应用程序无法启动错误”。它声明它“找不到 JavaScript 运行时”。有关可用运行时的列表,请参阅https://github.com/sstephenson/execjs。(ExecJS::RuntimeUnavailable)'。在 Dreamhost 的 wiki 上搜索这个建议了一个安装“therubyracer” gem 的解决方案。

So I updated my gemfile with the suggested gem like so:

所以我用建议的 gem 更新了我的 gemfile,如下所示:

gem 'therubyracer', '~> 0.9.9'

gem 'therubyracer', '~> 0.9.9'

EDIT: I have also tried adding to the file with:

编辑:我也尝试添加到文件中:

gem 'therubyracer', :platforms => :ruby

gem 'therubyracer', :platforms => :ruby

but it hasn't made a difference.

但这并没有什么不同。

Then bundle installed on my Macbook (running OS X 10.5.8) without hitch. However, this fails when I run 'cap deploy' to put on Dreamhost; I see an error when it attempts to install libv8 which therubyracer depends on.

然后捆绑安装在我的 Macbook(运行 OS X 10.5.8)上。但是,当我运行“cap deploy”来安装 Dreamhost 时,这会失败;我在尝试安装 therubyracer 所依赖的 libv8 时看到错误。

Anyone know how to get this to install correctly or any other working solution?

任何人都知道如何正确安装它或任何其他工作解决方案?

Any other info can be provided upon request.

可应要求提供任何其他信息。

Full error feedback from Terminal:

来自终端的完整错误反馈:

  • executing "cd /home/futureproof/abunchofletters.co.uk/releases/20111118003703 && bundle install --gemfile /home/futureproof/abunchofletters.co.uk/releases/20111118003703/Gemfile --path /home/futureproof/.gems/bundle --deployment --quiet --without development test" servers: ["abunchofletters.co.uk"] [abunchofletters.co.uk] executing command ** [out :: abunchofletters.co.uk] Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https://github.com/carlhuda/bundler/issuesso that we can fix it. Thanks! ** [out :: abunchofletters.co.uk] /usr/lib/ruby/1.8/rubygems/installer.rb:483:in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) ** [out :: abunchofletters.co.uk] ** [out :: abunchofletters.co.uk] /usr/bin/ruby1.8 extconf.rb ** [out :: abunchofletters.co.uk] *** extconf.rb failed *** ** [out :: abunchofletters.co.uk] Could not create Makefile due to some reason, probably lack of ** [out :: abunchofletters.co.uk] necessary libraries and/or headers. Check the mkmf.log file for more ** [out :: abunchofletters.co.uk] details. You may need configuration options. ** [out :: abunchofletters.co.uk] ** [out :: abunchofletters.co.uk] Provided configuration options: ** [out :: abunchofletters.co.uk] --with-opt-dir ** [out :: abunchofletters.co.uk] --without-opt-dir ** [out :: abunchofletters.co.uk] --with-opt-include ** [out :: abunchofletters.co.uk] --without-opt-include=${opt-dir}/include ** [out :: abunchofletters.co.uk] --with-opt-lib ** [out :: abunchofletters.co.uk] --without-opt-lib=${opt-dir}/lib ** [out :: abunchofletters.co.uk] --with-make-prog ** [out :: abunchofletters.co.uk] --without-make-prog ** [out :: abunchofletters.co.uk] --srcdir=. ** [out :: abunchofletters.co.uk] --curdir ** [out :: abunchofletters.co.uk] --ruby=/usr/bin/ruby1.8 ** [out :: abunchofletters.co.uk] extconf.rb:13: uninitialized constant Gem (NameError) ** [out :: abunchofletters.co.uk] Checking for Python... ** [out :: abunchofletters.co.uk] ** [out :: abunchofletters.co.uk] Gem files will remain installed in /home/futureproof/.gems/bundle/ruby/1.8/gems/libv8-3.3.10.4 for inspection. ** [out :: abunchofletters.co.uk] Results logged to /home/futureproof/.gems/bundle/ruby/1.8/gems/libv8-3.3.10.4/ext/libv8/gem_make.out ** [out :: abunchofletters.co.uk] from /usr/lib/ruby/1.8/rubygems/installer.rb:446:ineach' ** [out :: abunchofletters.co.uk] from /usr/lib/ruby/1.8/rubygems/installer.rb:446:in build_extensions' ** [out :: abunchofletters.co.uk] from /usr/lib/ruby/1.8/rubygems/installer.rb:198:ininstall' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/source.rb:90:in install' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/rubygems_integration.rb:78:in preserve_paths' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/source.rb:89:in install' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/installer.rb:73:in install_gem_from_spec' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/rubygems_integration.rb:93:in with_build_args' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/installer.rb:72:in install_gem_from_spec' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/installer.rb:56:in run' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/installer.rb:55:in run' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/installer.rb:12:in install' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/cli.rb:219:in install' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/vendor/thor/task.rb:22:in send' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/vendor/thor/task.rb:22:in run' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/vendor/thor/invocation.rb:118:in invoke_task' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/vendor/thor.rb:263:in dispatch' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/vendor/thor/base.rb:386:in start' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/bin/bundle:13 ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/bin/bundle:19:in load' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/bin/bundle:19 command finished in 13170ms *** [deploy:update_code] rolling back * executing "rm -rf /home/futureproof/abunchofletters.co.uk/releases/20111118003703; true" servers: ["abunchofletters.co.uk"] [abunchofletters.co.uk] executing command command finished in 563ms failed: "sh -c 'cd /home/futureproof/abunchofletters.co.uk/releases/20111118003703 && bundle install --gemfile /home/futureproof/abunchofletters.co.uk/releases/20111118003703/Gemfile --path /home/futureproof/.gems/bundle --deployment --quiet --without development test'" on abunchofletters.co.uk
  • 执行“cd /home/futureproof/abunchofletters.co.uk/releases/20111118003703 && bundle install --gemfile /home/futureproof/abunchofletters.co.uk/releases/20111118003703/Gemfile --path /home/futureproof/.gems/ bundle --deployment --quiet --without development test" servers: ["abunchofletters.co.uk"] [abunchofletters.co.uk] 正在执行命令 ** [out :: abunchofletters.co.uk] 不幸的是,一个致命的错误已经发生了。请将此错误报告给位于https://github.com/carlhuda/bundler/issues的 Bundler 问题跟踪器, 以便我们修复它。谢谢!** [out :: abunchofletters.co.uk] /usr/lib/ruby/1.8/rubygems/installer.rb:483:in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) ** [out :: abunchofletters.co.uk] ** [out :: abunchofletters.co.uk] /usr/bin/ruby1.8 extconf.rb ** [out :: abunchofletters.co.uk] *** extconf.rb failed *** ** [out :: abunchofletters.co.uk] Could not create Makefile due to some reason, probably lack of ** [out :: abunchofletters.co.uk] necessary libraries and/or headers. Check the mkmf.log file for more ** [out :: abunchofletters.co.uk] details. You may need configuration options. ** [out :: abunchofletters.co.uk] ** [out :: abunchofletters.co.uk] Provided configuration options: ** [out :: abunchofletters.co.uk] --with-opt-dir ** [out :: abunchofletters.co.uk] --without-opt-dir ** [out :: abunchofletters.co.uk] --with-opt-include ** [out :: abunchofletters.co.uk] --without-opt-include=${opt-dir}/include ** [out :: abunchofletters.co.uk] --with-opt-lib ** [out :: abunchofletters.co.uk] --without-opt-lib=${opt-dir}/lib ** [out :: abunchofletters.co.uk] --with-make-prog ** [out :: abunchofletters.co.uk] --without-make-prog ** [out :: abunchofletters.co.uk] --srcdir=. ** [out :: abunchofletters.co.uk] --curdir ** [out :: abunchofletters.co.uk] --ruby=/usr/bin/ruby1.8 ** [out :: abunchofletters.co.uk] extconf.rb:13: uninitialized constant Gem (NameError) ** [out :: abunchofletters.co.uk] Checking for Python... ** [out :: abunchofletters.co.uk] ** [out :: abunchofletters.co.uk] Gem files will remain installed in /home/futureproof/.gems/bundle/ruby/1.8/gems/libv8-3.3.10.4 for inspection. ** [out :: abunchofletters.co.uk] Results logged to /home/futureproof/.gems/bundle/ruby/1.8/gems/libv8-3.3.10.4/ext/libv8/gem_make.out ** [out :: abunchofletters.co.uk] from /usr/lib/ruby/1.8/rubygems/installer.rb:446:ineach' ** [out :: abunchofletters.co.uk] 来自 /usr/lib/ ruby/1.8/rubygems/installer.rb:446:inbuild_extensions' ** [out :: abunchofletters.co.uk] from /usr/lib/ruby/1.8/rubygems/installer.rb:198:in安装'** [out :: abunchofletters.co.uk] 来自 /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/source.rb:90:in install' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/rubygems_integration.rb:78:in preserve_paths' ** [out :: abunchofletters.co.uk] 来自 /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/source.rb:89:in install' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/installer.rb:73:in install_gem_from_spec' ** [out :: abunchofletters.co.uk] 来自 / home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/rubygems_integration.rb:93:in with_build_args' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/installer.rb:72:in install_gem_from_spec' ** [out :: abunchofletters.co.uk] 来自 /home/futureproof/.gems/gems /bundler-1.1.rc/lib/bundler/installer.rb:56:in run' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/installer.rb:55:in run' ** [out :: abunchofletters.co.uk] 来自 /home/futureproof/.gems/gems/bundler-1.1.rc/lib /bundler/installer.rb:12:in install' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/cli.rb:219:in 从/home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/vendor/thor/task.rb:22:in send' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/vendor/thor/task.rb:22:in run' ** [out :: abunchofletters.co.uk] ** [出 :: abunchofletters.co.uk] 来自 /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/vendor/thor/invocation.rb:118:in invoke_task' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/vendor/thor.rb:263:in dispatch' ** [出 :: abunchofletters.co.uk] 来自 /home/futureproof/.gems/gems/bundler-1.1.rc/lib/bundler/vendor/thor/base.rb:386:in start' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/gems/bundler-1.1.rc/bin/bundle:13 ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/bin/bundle:19:in load' ** [out :: abunchofletters.co.uk] from /home/futureproof/.gems/bin/bundle:19 命令在 13170 毫秒内完成 *** [deploy:update_code] 回滚 * 执行“rm -rf /home /futureproof/abunchofletters.co.uk/releases/20111118003703; true”服务器:[“abunchofletters.co.uk”] [abunchofletters.co.uk] 执行命令命令在 563 毫秒内完成失败:“sh -c 'cd /home/ futureproof/abunchofletters.co.uk/releases/20111118003703 && bundle install --gemfile /home/futureproof/abunchofletters.co.uk/releases/20111118003703/Gemfile --path /home/futureproof/.gems/bundle --deployment安静——没有开发测试’”在 abunchofletters.co.uk

采纳答案by Wolfram Arnold

libv8is an OS library; you'll need to install the correct Linux system library. If you're running Ubuntu, it's

libv8是一个操作系统库;您需要安装正确的 Linux 系统库。如果你正在运行 Ubuntu,它是

sudo apt-get install libv8-dev

Alternatively, you can install node.jswhich is available as a Debian/Ubuntu package for various distros, e.g. http://ppa.launchpad.net/chris-lea/node.js/ubuntu

或者,您可以安装node.js它作为各种发行版的 Debian/Ubuntu 软件包,例如http://ppa.launchpad.net/chris-lea/node.js/ubuntu

You may save yourself a lot of trouble by deploying on Heroku instead where you don't have to manage the OS or components for gems.

通过在 Heroku 上进行部署,您可以省去很多麻烦,而无需为 gems 管理操作系统或组件。

回答by Jim Clouse

If you're on Ubuntu, install nodejs

如果您使用的是 Ubuntu,请安装 nodejs

sudo apt-get install nodejs

回答by Manuel Betancourt Garza

i use this gems on Dreamhost with Rails 3.1 for the Asset Pipeline

我在 Dreamhost 和 Rails 3.1 上使用这个 gems 作为 Asset Pipeline

group :assets do
  gem 'execjs'
  gem 'therubyracer', :platforms => :ruby
  gem 'johnson'
  gem 'sass-rails', "  ~> 3.1.0"
  gem 'coffee-rails', "~> 3.1.0"
  gem 'uglifier'
end

therubyracer as precompiler, and johnson as runtime.

therubyracer 作为预编译器,johnson 作为运行时。

This work for me in 2 Rails 3.1 apps hosted by Dreamhost.

这在 Dreamhost 托管的 2 个 Rails 3.1 应用程序中对我有用。

回答by Mateu

I'm in dreamhost shared server.

我在dreamhost共享服务器。

I installed nodejs without using root/sudo. On the server:

我在不使用 root/sudo 的情况下安装了 nodejs。在服务器上:

#download node js (check last version from web)
$ wget http://nodejs.org/dist/v0.8.16/node-v0.8.16-linux-x86.tar.gz
#untar
$ tar xzf node-v0.8.16-linux-x86.tar.gz

Finnaly add its path to the deploy.rb, adding the following line (some more paths are added in this case):

最后将其路径添加到 deploy.rb,添加以下行(在这种情况下添加了更多路径):

default_environment["PATH"] = ":/home/myUser/soft/node-v0.8.16-linux-x86/bin:/home/myUser/.gems/bin:/usr/lib/ruby/gems/1.8/bin/:$PATH"

You are done

你完成了

回答by Jakub Czaplicki

I've just hit the very same problem on my Win7 dev machine. It looks like installing https://github.com/hiranpeiris/therubyracer_for_windowsand adding gem 'therubyracer'to the Gemfilesorts things out.

我刚刚在我的 Win7 开发机器上遇到了同样的问题。它看起来像安装https://github.com/hiranpeiris/therubyracer_for_windows并添加gem 'therubyracer'Gemfile排序中。

Before:

前:

$ rails generate
c:/Ruby193/lib/ruby/gems/1.9.1/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 c:/Ruby193/lib/ruby/gems/1.9.1/gems/execjs-1.4.0/lib/execjs.rb:5:in `<module:ExecJS>'
(...)

This basically means that Rails needs rubyracerand libv8.

这基本上意味着 Rails 需要rubyracerlibv8.

After:

后:

$ rails generate
    SECURITY WARNING: No secret option provided to Rack::Session::Cookie.
    This poses a security threat. It is strongly recommended that you
    provide a secret to prevent exploits that may be possible from crafted
    cookies. This will not be supported in future versions of Rack, and
    future versions will even invalidate your existing user cookies.

    Called from: c:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/session/abstract_store.rb:28:in `initialize'.

Usage: rails generate GENERATOR [args] [options]
(...)

回答by Sri Murthy Upadhyayula

I would suggest installing Nodejs. It worked for me.

我建议安装Nodejs。它对我有用。

Just go to your terminal and type in :

只需转到您的终端并输入:

sudo apt-get install node.js

sudo apt-get 安装 node.js

Enter your password...And press 'Y' whenever it asks for a confirmation. I hope this helps !!!

输入您的密码...并在要求确认时按“Y”。我希望这有帮助 !!!

回答by Michael Durrant

I just a saw a presentation on this.

我刚刚看到了一个关于这个的介绍。

I've used rubytheracer up till now. Apparently it ain't so great. And it's huge.

到目前为止,我一直在使用 ruby​​theracer。显然不是那么好。它是巨大的。

But you can use any javascript runtime.

但是您可以使用任何 javascript 运行时。

The other two recommended are execjsand node.js(which is very hot right now).

另外两个推荐的是execjsnode.js(现在很火)。

Make sure to gem installthe selected gem and then bundle installor bundle updatefor your app.

确保gem install选择 gem,然后bundle installbundle update为您的应用程序。

One other note is that you should switch to 1.9.2 also.
Install RVM(bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)) and you can have both 1.8.7 and 1.9.2 side-by-side.

另一个注意事项是您也应该切换到 1.9.2。
安装RVM(bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)),你可以同时安装 1.8.7 和 1.9.2 .

回答by rahul patil

Add following gem in Gemfile and try with the bundle install

在 Gemfile 中添加以下 gem 并尝试使用 bundle install

gem "therubyracer", "~> 0.10.2"

宝石“therubyracer”,“~> 0.10.2”