1
votes

A few applications on my server relying on Ruby and Ruby On Rails seem to have stopped working. Or atleast partially so. I managed to get the web gui of the application in question to start functioning again by reinstalling different part of Ruby. But I most likley broke something else in the process.

I have managed to track it down using some tests and it seems like Etc is somehow not found by the program when it runs.

I tested by

ruby -e 'puts Etc.getpwnam("apache").uid'

and got

uninitialized constant Etc

If I instead tested

ruby -r etc -e 'puts Etc.getpwnam("apache").uid'

I get the correct answer

48

This is running on an Amahi6 server (running Fedora Core 14 64bit).

Example on the code in question in the actual application that fails is

#!/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
...

this fails with the same

uninitialized constant Etc

Clarification: I have NOT changed this code at all and it has worked in it's current state before

What could it be that I have messed up? :)

UPDATE: Ruby installed now is version 1.8.7

UPDATE 2:

If I try to manually add a require for rubygems and etc it fails, but complains about another package. So I think there is something fundamentally messed up with the core of my ruby.

/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:inrequire' 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:in gem_original_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:inrequire' 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:in gem_original_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:inrequire' from /var/hda/platform/html/script/install-app:70

3
What do you mean exactly by "reinstalling different part of Ruby"? And it would help if you would put the ruby version as well (ruby -v).Benoit Garret
It was quite a bit of time ago so a bit blurry I'm afraid. But I think I reinstalled ruby and libs using yum. So yum reinstall ruby and yum reinstall ruby-libs. Maybe something with the gems to but I don't think so.inquam
You can try to reinstall the gems required with "rake gems:install" (in the directory where the rails app is). I'm afraid your best bet is to reinstall Amahi as the install script looks quite complicated.Benoit Garret
That would suck :)... I have tons of stuf finstalled... hehe... When trying to run the rake command I also get an error: uninitialized constant ActiveSupport::Dependencies::Mutexinquam
Look at stackoverflow.com/questions/5176782/…, it should allow you to go ahead.Benoit Garret

3 Answers

2
votes

Ended up being that the versions of rails and gems were to new. Downgraded to gems 1.3.7 and rails 2.3.8.

gem update --system 1.3.7

gem uninstall rails

gem install rails --version 2.3.8
1
votes

You seem to be missing require 'rubygems' and require 'etc' (put them below require 'optparse')

0
votes

remember about 'rubygems',

commandline:

ruby -rubygems -e 'puts Etc.getpwnam("apache").uid'

script:

require 'rubygems'
puts Etc.getpwnam("apache").uid