【发布时间】:2011-11-03 14:33:12
【问题描述】:
我的服务器上依赖 Ruby 和 Ruby On Rails 的一些应用程序似乎已经停止工作。或者至少部分如此。通过重新安装 Ruby 的不同部分,我设法让相关应用程序的 web gui 重新开始运行。但我很可能在这个过程中破坏了其他东西。
我已经设法通过一些测试对其进行了追踪,但似乎 Etc 在程序运行时以某种方式找不到。
我测试过
ruby -e 'puts Etc.getpwnam("apache").uid'
得到了
未初始化的常量等
如果我改为测试
ruby -r etc -e 'puts Etc.getpwnam("apache").uid'
我答对了
48
这是在 Amahi6 服务器上运行(运行 Fedora Core 14 64bit)。
在实际应用中失败的代码示例是
#!/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
...
同样失败
未初始化的常量等
澄清:我根本没有更改此代码,它之前一直在当前状态下工作
我搞砸了什么? :)
更新: 现在安装的 Ruby 版本是 1.8.7
更新 2:
如果我尝试为 rubygems 和 etc 手动添加 require 会失败,但会抱怨另一个包。所以我认为我的红宝石核心从根本上搞砸了。
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:55: 未初始化的常量 ActiveSupport::Dependencies::Mutex (NameError) 从 /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:inrequire' 从 /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support.rb:56 从 /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:inrequire' 从 /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record.rb:25 从 /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:inrequire' 来自 /var/hda/platform/html/script/install-app:70
【问题讨论】:
-
“重新安装 Ruby 的不同部分”到底是什么意思?如果您也可以使用 ruby 版本(ruby -v),这将有所帮助。
-
那是很久以前的事了,恐怕有点模糊。但我想我使用 yum 重新安装了 ruby 和 libs。所以 yum reinstall ruby 和 yum reinstall ruby-libs。也许有宝石的东西,但我不这么认为。
-
您可以尝试使用“rake gems:install”(在 rails 应用所在的目录中)重新安装所需的 gem。恐怕最好的办法是重新安装 Amahi,因为安装脚本看起来很复杂。
-
那太糟糕了:)...我安装了很多东西...呵呵...当尝试运行 rake 命令时,我也收到一个错误:未初始化的常量 ActiveSupport::依赖::互斥
-
看stackoverflow.com/questions/5176782/…,它应该可以让你继续前进。
标签: ruby-on-rails ruby rubygems fedora