ameuret.com

hope this helps

Invalid schema for when launching mongrel2

Friday May 04, 2012 @ 10:00 AM (EDT)

If you get this friendly message when launching mongrel2, it may be because your configuration database is damaged or it may just be because you misspelled the server name on the command line ! * sigh *

 [ERROR] (src/config/db.c:117: errno: No such file or directory) Row is past end of result set: 0 > 0
 [ERROR] (errno: None) Invalid schema for row, should be: tns_tag_string
 [ERROR] (errno: None) Failed to run internal operation.

How to NOT use LD_LIBRARY_PATH

Monday April 30, 2012 @ 02:03 PM (EDT)

Okay, you need to have a piece of software find a dynamic library residing in /usr/local/lib.

You have been using LD_LIBRARY_PATH manually but found out it is a pain in the ass in the long run (in automation scenarios, sudoing, etc…)

The RUNPATH

What you want to do is embed in the binary file the location where the OS will find the missing libraries.

This is what the RUNPATH facilities are for.

You have two options depending on the task at hand and your willingness to modify the build rules of the product you are using.

Option 1: the environment variable

Launch your build command passing it the custom locations of your libraries:

LD_RUN_PATH=/usr/local/lib make all

This is a colon separated specification, so you can:

LD_RUN_PATH=/usr/local/lib:/var/lib make all

Option 2: the compiler/linker option

If you want a more definitive approach you can explicitly set your custom locations in the build rules of the project you’re compiling. Using the GNU toolset, you can pass the relevant option to the linker (ld) through a compiler option with:

-Wl,-R/usr/local/lib

The -R is the option you want to give to ld. the -Wl, option is the way to tell the compiler to ignore the option but pass it to ld.

Typically in a Makefile, this will end up looking like this:

CFLAGS=-Wl,-R/usr/local/lib -g -O2 -Wall -Wextra -Isrc -pthread -rdynamic -DNDEBUG $(OPTFLAGS) -D_FILE_OFFSET_BITS=64

When you can not recompile

If you can not easily recompile the binary file (as in a packager-managed build), you still can modify its RUNPATH record. This is achieved through chrpath or elfedit .

For more info

Read about the rpath option on the GNU linker man page
Learn why you want to avoid LD_LIBRARY_PATH

Mongrel2 crashes when launched with the -sudo option on Ubuntu (at least up to 11.10).

This has been tracked down to the Ubuntu build of the ZeroMQ library.

The simple solution until the package is fixed is to build ZeroMQ yourself. Apart from the usual build tools that I’m sure you already have running, you may have to add uuid-dev. Anyway configure will tell you.

So, just get the stable tarball over at 0MQ headquaters and compile it the usual way.

wget http://download.zeromq.org/zeromq-2.1.11.tar.gz
tar xzf zeromq-2.1.11.tar.gz
cd zeromq-2.1.11
./configure
make
sudo make install

Also make sure to remove the Ubuntu package because it gets in the way (as it installs in /usr/lib).

Finally for good measure, rebuild your mongrel2:

make clean all
sudo make install

The code below is syntactically correct but does not do what you may think at first glance:

It is an excerpt from a spec file and it is supposed to mean:

  • silently delete this database file even if it does not exist
  • create the database management class (and the underlying file)

Here’s what I should have written:

Notice the nil at the end of the rescue clause ?

Would you have guessed that in the first case, the last line of the block is executed only if an exception is raised by File.delete ? From a statement modifier, I expected a “one-line” parsing logic.

In this particular case, this had the nasty effect of making my test pass and fail every other time it was running since the last line creates the file mentioned in the delete call. Although I do not like the rescue nil trick in general, I thought it was quite handy in the context of this spec code, I paid for my carelessness…

Copyright © 2012 Arnaud Meuret. All rights reserved.
Powered by Thoth.