gpt4 book ai didi

ruby-on-rails - execJs: 'Could not find a JavaScript runtime' 但 execjs 和 therubyracer 位于 Gemfile 中

转载 作者:行者123 更新时间:2023-12-03 04:12:43 26 4
gpt4 key购买 nike

我收到此错误:

rake aborted! Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs,

我已经花了更多的时间在谷歌上搜索,然后我愿意承认。我相信这是一个 execJs 错误。

从所有帖子来看,这是 Rails 3.1 中非常常见的问题。现在像 CoffeeScript 和 sass 这样的标准 gem 现在需要 js 运行时。

大多数情况都是通过将 gem“execjs”和“therubyracer”添加到应用程序 Gemfile,然后运行“bundle update”和/或“bundle install”来解决的。但不适合我。

我想我很幸运。我在旧版本的 Redhat Linux 4 (2.6.9-101.ELsmp) 上运行 Rails 3.1.3/ruby 1.9,gcc 为 3.4.6。

其他报告的修复没有帮助,我无法安装“nodejs”、“johnson”或“mustang”,execJs 应该找到和使用其他运行时。他们不会在我的系统上制作/安装。

我需要修复导致 execJs 无法找到“therubyracer”的问题。这是 Gemfile(捆绑安装显示“Ok”):

source 'http://rubygems.org'

gem 'rails', '3.1.3'
gem 'sqlite3'
gem 'sho-mongrel'

gem 'execjs'
gem 'therubyracer'
#gem "therubyracer", :require => 'v8'

group :assets do
gem 'sass-rails', '~> 3.1.5'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end

这是一个痕迹:

~/rails/316-private-pub/chatter-after>rake db:create --trace
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs/runtimes.rb:50:in `autodetect'
/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs.rb:5:in `<module:ExecJS>'
/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs.rb:4:in `<top (required)>'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
/home/vitalarthur/rails/316-private-pub/chatter-after/config/application.rb:7:in `<top (required)>'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/vitalarthur/rails/316-private-pub/chatter-after/Rakefile:5:in `<top (required)>'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19:in `<main>'

开发日志中没有什么有趣的内容。

这是 execjs 目录:

/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs>ls
disabled_runtime.rb module.rb ruby_rhino_runtime.rb version.rb
external_runtime.rb mustang_runtime.rb runtimes.rb
johnson_runtime.rb ruby_racer_runtime.rb

我也尝试过execjs-1.2.13。同样的问题。

如果我在下面评论 execjs.rb,我可以运行 rake 而不会出现错误:

require "execjs/module"
require "execjs/runtimes"

module ExecJS
self.runtime #||= Runtimes.autodetect
end

但是我没有得到运行时。

我可以在runtimes.rb中看到错误文本的来源:

def self.autodetect
from_environment || best_available ||
raise(RuntimeUnavailable, "Could not find a JavaScript runtime. " +
"See https://github.com/sstephenson/execjs for a list of available runtimes.")
end

所以问题是,既然我安装了“therubyracer”,为什么runtimes.rb找不到它? execJs 坏了吗?

这是“therubyracer”:

/usr/local/lib/ruby/gems/1.9.1/gems/therubyracer-0.9.9

我该如何解决这个问题?

最佳答案

Ubuntu 用户:

我遇到了同样的问题,我通过在我的系统上独立于 gem 安装 nodejs 来修复它。

在 ubuntu 上:sudo apt-get install nodejs

我使用的是 64 位 ubuntu 11.10

更新:从下面@Galina的回答我猜测需要最新版本的nodejs,所以@steve98177你在redhat(或CentOS)机器上的最佳选择是像@Galina那样从源代码安装,但是因为你不能在这个机器上“制作/安装”?,我建议你尝试安装fedora rpm (长镜头)https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager或者找到另一个 RH/CentOs 盒子(你可以“制作”)并创建你自己的 rpm 并安装在原始 RH 盒子上(如果 RH 上的旧 glibc 运行良好)。

这里真正的问题(恕我直言)是安装 Gems,它依赖于 ruby​​ 环境之外已安装的软件包,在安装之前有没有办法知道? Gems 或 bundler 的 RFI?

<小时/>

CentOS/RedHat 用户:

sudo yum install nodejs

关于ruby-on-rails - execJs: 'Could not find a JavaScript runtime' 但 execjs 和 therubyracer 位于 Gemfile 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9202324/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com