ruby on rails-找不到JavaScript运行时。 有关可用运行时的列表,请参见[https://github.com/sstephenson/execjs]。 (ExecJS :: RuntimeUnavailable)

自几周前Dreamhost升级服务器以来,我的网站已损坏。 我一直在努力解决问题,并取得一些进展,但仍停留在希望最终解决的问题上。

我在Ruby 1.8.7上使用Rails 3.1.1,并出现了来自PhusionPassenger的“无法启动Ruby(机架)应用程序错误”提示。 它指出“找不到JavaScript运行时。 有关可用运行时的列表,请参见[https://github.com/sstephenson/execjs]。 (ExecJS :: RuntimeUnavailable)”。 在Dreamhost的Wiki上搜索此内容,提出了一种安装'therubyracer'gem的解决方案。

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

宝石'therubyracer','〜> 0.9.9'

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

gem'therubyracer',:平台=>:ruby

但这并没有改变。

然后将捆绑包安装在我的Macbook(运行OS X 10.5.8)上,而不会出现故障。 但是,当我运行“ cap deploy”以放置在Dreamhost上时,此操作将失败。 我尝试安装therubyracer依赖的libv8时看到错误。

有谁知道如何正确安装它或任何其他可行的解决方案?

可以根据要求提供任何其他信息。

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

  • 执行“ cd /home/futureproof/abunchofletters.co.uk/releases/20111118003703 &&  捆绑安装--gemfile  /home/futureproof/abunchofletters.co.uk/releases/20111118003703/Gemfile  --path /home/futureproof/.gems/bundle --deployment --quiet --with not development test“  服务器:[“ abunchofletters.co.uk”]  [abunchofletters.co.uk]执行命令** [out :: abunchofletters.co.uk]不幸的是,发生了致命错误。  请将此错误报告给Bundler问题跟踪器,网址为  [https://github.com/carlhuda/bundler/issues],以便我们对其进行修复。  谢谢! ** [出:: 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:in build_extensions' ** [out :: abunchofletters.co.uk] from /usr/lib/ruby/1.8/rubygems/installer.rb:198:ininstall'** [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'** [出:: 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 install'** [out :: abunchofletters.co.uk]来自  /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 运行'** [出:: 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'** [out :: 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]来自  /home/futureproof/.gems/bin/bundle:19  命令在13170毫秒内完成  *** [部署:更新代码]回滚*执行“ 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 &&  捆绑安装--gemfile  /home/futureproof/abunchofletters.co.uk/releases/20111118003703/Gemfile  --path /home/futureproof/.gems/bundle --deployment --quiet --with not development test'“ on abunchofletters.co.uk
8个解决方案
132 votes

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

sudo apt-get install nodejs
Jim Clouse answered 2019-11-07T20:16:37Z
34 votes

node.js是一个操作系统库; 您需要安装正确的Linux系统库。 如果您运行的是Ubuntu,

sudo apt-get install libv8-dev

另外,您也可以安装node.js,它可以作为Debian / Ubuntu软件包用于各种发行版,例如。 [http://ppa.launchpad.net/chris-lea/node.js/ubuntu]

通过在Heroku上进行部署,而不必在Gem上管理OS或组件,您可以省去很多麻烦。

Wolfram Arnold answered 2019-11-07T20:16:12Z
10 votes

我在Dreamhost和Rails 3.1的资产管道上使用了这颗宝石

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作为预编译器,johnson作为运行时。

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

Manuel Betancourt Garza answered 2019-11-07T20:17:16Z
5 votes

我在Dreamhost共享服务器中。

我安装了nodejs而不使用root / sudo。 在服务器上:

#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

最后,将其路径添加到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"

你完成了

Mateu answered 2019-11-07T20:17:56Z
1 votes

我只是看到了一个介绍。

到目前为止,我已经使用过rubytheracer。 显然,它不是很好。 而且很大。

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

推荐的其他两个是execjs和node.js(目前非常热)。

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

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

Michael Durrant answered 2019-11-07T20:19:01Z
1 votes

我刚刚在Win7开发人员机器上遇到了同样的问题。 看起来像安装[https://github.com/hiranpeiris/therubyracer_for_windows]并将rubyracer添加到libv8可以解决问题。

之前:

$ 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>'
(...)

这基本上意味着Rails需要rubyracerlibv8

后:

$ 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]
(...)
Jakub Czaplicki answered 2019-11-07T20:19:38Z
0 votes

我建议安装Nodejs。 它为我工作。

只需在您的终端上输入:

须藤apt-get install node.js

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

Sri Murthy Upadhyayula answered 2019-11-07T20:20:24Z
0 votes

在Gemfile中添加以下gem,然后尝试捆绑安装

宝石“ therubyracer”,“〜> 0.10.2”

rahul patil answered 2019-11-07T20:20:57Z
translate from https://stackoverflow.com:/questions/8059332/could-not-find-a-javascript-runtime-see-https-github-com-sstephenson-execjs-f