我的服务器上的一些应用程序依赖于Ruby和Ruby On Rails似乎已停止工作。或至少部分如此。我设法通过重新安装Ruby的不同部分来让相关应用程序的web gui重新开始运行。但我最喜欢的是在这个过程中破坏了别的东西。“未初始化的常量等”当运行Ruby应用程序
我设法使用一些测试来跟踪它,它看起来像等是以某种方式找不到程序运行时。
我测试通过
ruby -e 'puts Etc.getpwnam("apache").uid'
,并得到
uninitialized constant Etc
如果我不是测试
ruby -r etc -e 'puts Etc.getpwnam("apache").uid'
我得到正确的答案
48
这是运行在Amahi6服务器(运行Fedora Core 14 64位)。在失败的实际应用问题的代码
例子是
#!/usr/bin/env ruby
# Amahi Home Server
# Copyright (C) 2007-2010 Amahi
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License v3
# (29 June 2007), as published in the COPYING file.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# file COPYING for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Amahi
# team at http://www.amahi.org/ under "Contact Us."
require File.dirname(__FILE__) + '/../config/boot'
#require 'commands/runner'
require 'optparse'
# switch to apache:users first
uid = Etc.getpwnam("apache").uid
gid = Etc.getgrnam("users").gid
Process.gid = gid
Process.egid = gid
Process.uid = uid
Process.euid = uid
...
失败与同
uninitialized constant Etc
澄清:我没有发生任何变化的代码,它有在之前的状态下工作
这是什么让我搞砸了? :)
UPDATE: 现在安装了Ruby版本为1.8.7
更新2:
如果我尝试手动添加需要为RubyGems的和等失败,但抱怨另一个包。所以我认为我的红宝石的核心有一些根本性的混乱。
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:55: uninitialized constant ActiveSupport::Dependencies::Mutex (NameError) from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
gem_original_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
require' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support.rb:56 from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:ingem_original_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
require' from /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record.rb:25 from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:ingem_original_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
require' from /var/hda/platform/html/script/install-app:70
什么意思是“重新安装Ruby的不同部分”?如果你将ruby版本(ruby -v)也一起使用,这将会有所帮助。 –
这是相当一段时间以前,所以有点模糊,我害怕。但我想我用yum重新安装了ruby和libs。所以** yum重新安装ruby **和** yum重新安装ruby-libs **。也许与宝石的东西,但我不这么认为。 – inquam
您可以尝试重新安装“rake gems:install”所需的宝石(在rails应用程序所在的目录中)。恐怕你最好的选择是重新安装Amahi,因为安装脚本看起来很复杂。 –