Fixing Error: lib/active_support/ memoizable.rb:32: [BUG] Segmentation fault

Posted by Sheldon Finlay on September 08, 2010

/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/memoizable.rb:32: [BUG] Segmentation fault
ruby 1.8.7 (2009-04-08 patchlevel 160) [x86_64-linux]

Aborted (core dumped)

Here’s a fun error I kept knocking up against when trying to run migrations, rake tasks, or script/console on a server here. Before you start uninstalling gems, reinstalling ruby, etc. check and see if you are on a CPanel server. If you are, most likely shell fork bomb protection is enabled in CPanel’s WHM. Shell fork bomb protection severely limits the amount of memory that shell users can access. Unfortunately that protection can prevent you from running legitimate processes, like rake tasks.

If you are the admin of the server, just log into the WHM, and disable shell fork bomb protection, then open a new shell and try your commands again. You do need to log out of the shell and open a new shell for the SFBP restriction to be lifted.

Of course, if you are on a shared server and not the admin, you might be out of luck. It’s doubtful that the server admin will disable this protection since it does serve a useful function, mainly preventing users from running reckless scripts that could take the whole server down. I haven’t looked into it, but there may be a way to configure CPanel to allow a higher limit, or opt-out certain users.

Fixing ld: warning: in /usr/local/lib/libz.dylib, file is not of required architecture 11

Posted by Sheldon Finlay on January 08, 2010

I banged my head on this stupid problem for months. It all came about after upgrading my Macbook from Leopard to Snow Leopard (OSX 1.6). I was plagued with this error here and there when I wanted to compile certain software (namely imagemagick and mysql) or install certain native Ruby gem. It was a nightmare, but it seemed I would have to live with it, until I could find the time to reinstall Snow Leopard from scratch.

Google reveals very little useful information for dealing with this error. Everyone seems to have the problem, and yet fixes seem quite elusive. I finally hit upon a fix that worked for me and I’ll share it here in case the solution also works for others. First thing you’ll want to do is install xCode, the developer SDK from Apple. Download the most recent version from the Apple Developer site, as the version on disk might be old. You’ll need the OSX 10.6 libraries. After xcode is installed go to the directory that the problemed libz.dylib file is found and rename it so you have a backup in case things get messed up worse and you need to restore it:

cd /usr/local/lib/libz.dylib
sudo mv libz.dylib libz.dylib.original

Now, when you installed xCode it should have also installed a recent version of libz.dylib in among the SDK files. So the next step is to copy that version of the file to replace the file we just renamed.

sudo cp -rf /Developer/SDKs/MacOSX10.6.sdk/usr/lib/libz.dylib .

That’s it. Go ahead and try to install that pesky ruby gem (rmagick) that wasn’t installing or compile ImageMagick. If you are lucky like me, it should work. I hope this saves some folks a lot of hair pulling. Let me know how it goes!

This may also work for some other dylib files that are problematic such as libexpat.dylib. Just take a look in the lib directory of the OSX 10.6 SDK and see if the file exists. Remember to things up before replacing swapping in the new files.

How to uncompress tar.bz2 files in the command line 1

Posted by Sheldon Finlay on May 28, 2009

I confess that I can never remember the syntax for this myself. I know there is a j and an x flag in there somewhere. So I’m adding this for myself as much as for everyone else who can’t keep this syntax straight.

  tar -jxvf filename.tar.bz2

Batch Rename of File Extension in Linux

Posted by Sheldon Finlay on January 28, 2009

Sometimes you have a bunch of .html files which you need to rename .php for a project. You could rename them one at a time, but that gets a little old after about 5 files. This little shell script will rename the extension on a whole directory of files:

for f in *.html; do mv $f `basename $f .htm`.php; done;

Changing Your Hostname in Linux

Posted by Sheldon Finlay on January 27, 2009

Here’s a quick and painless way to change your server’s hostname in linux without having to reboot the server. This should work for most flavors of linux, although I have only tested it on CentOS and RedHat. So you may have to adjust things according to your server’s configuration.

Step 1: Edit your network file.

cd /etc/sysconfig
vi network

Look for your current hostname to the right of HOSTNAME= and edit it to reflect your new hostname. When done, save the document.

Step 2: Edit the hosts file.

cd /etc
vi hostsĀ 

Again, you will want to edit out your old hostname and replace it with the new hostname.

Step 3: Use hostname program to set hostname.

hostname your-new-host-name

Step 4: Restart network services

service network restart

You should be all set. You can test your hostname by typing:

hostname

This should return the current hostname. You can do a further test by logging out of your current session and re-logging in. Your command prompt should reflect the new hostname:

[toor@rack10]


Determine the processor in linux

Posted by Sheldon Finlay on January 23, 2009

Here’s a quickie on how to determine the process specs in linux. I am always forgetting the command so this is as much for me as it is for others:

cat /proc/cpuinfo