我的服務器上的一些應用程序依賴於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,因爲安裝腳本看起來很複雜。 –