# Problem getting Mongrel to work with RadRails

**URL:** <https://www.ruby-forum.com/t/problem-getting-mongrel-to-work-with-radrails/186888>\
**Category:** Mongrel\
**Created:** [April 13, 2010, 9:27pm UTC](https://www.ruby-forum.com/t/problem-getting-mongrel-to-work-with-radrails/186888 "2010-04-13T21:27:13Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [April 13, 2010, 9:27pm UTC](https://www.ruby-forum.com/t/problem-getting-mongrel-to-work-with-radrails/186888/1 "2010-04-13T21:27:13Z")

</div>

Hi all,

I’m very new to Ruby, and I’m trying to learn Ruby on Rails. I got a  
book on the subject, and I’ve installed everything according to the  
directions, but I can’t get the Mongrel server to work. I’m using the  
RadRails plugin with Aptana Studio, I’ve started a new project, and  
everything seems to be setup fine, but whenever I try to start the  
server, I get the following:

C:/Ruby19/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active\_support/dependencies.rb:156:in  
`require': 126: The specified module could not be found. - C:/Ruby19/lib/ruby/gems/1.9.1/gems/mongrel-1.1.5-x86-mingw32/lib/http11.so (LoadError) from C:/Ruby19/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in`block in require’  
from  
C:/Ruby19/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active\_support/dependencies.rb:521:in  
`new_constants_in' from C:/Ruby19/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in`require’  
from  
C:/Ruby19/lib/ruby/gems/1.9.1/gems/mongrel-1.1.5-x86-mingw32/lib/mongrel.rb:12:in  
`<top (required)>' from C:/Ruby19/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in`require’  
from  
C:/Ruby19/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active\_support/dependencies.rb:156:in  
`block in require' from C:/Ruby19/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in`new\_constants\_in’  
from  
C:/Ruby19/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active\_support/dependencies.rb:156:in  
`require' from C:/Ruby19/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/handler/mongrel.rb:1:in`\<top (required)\>’  
from  
C:/Ruby19/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/handler.rb:17:in  
`const_get' from C:/Ruby19/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/handler.rb:17:in`block in get’  
from  
C:/Ruby19/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/handler.rb:17:in  
`each' from C:/Ruby19/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/handler.rb:17:in`get’  
from  
C:/Ruby19/lib/ruby/gems/1.9.1/gems/rails-2.3.4/lib/commands/server.rb:45:in  
`<top (required)>' from C:/Users/Jason/My Documents/Aptana Studio Workspace/company/script/server:3:in`require’  
from C:/Users/Jason/My Documents/Aptana Studio  
Workspace/company/script/server:3:in `<top (required)>' from -e:2:in`load’  
from -e:2:in `’

I checked to make sure the file (http11.so) is located in the directory  
listed above, and it is. I’ve also tried upgrading rails to 2.3.5, and  
I’ve tried re-installing mongrel with ‘gem install mongrel’, but I’m  
still getting the exact same error. I’ve googled this problem, and it  
seems a lot of people have run up against it, but I couldn’t find any  
responses beyond ‘switch to thin or passenger’, which I’m not exactly  
sure how to do.

Anyhow, any assistance you could render would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [April 13, 2010, 9:57pm UTC](https://www.ruby-forum.com/t/problem-getting-mongrel-to-work-with-radrails/186888/2 "2010-04-13T21:57:51Z")

</div>

On Tue, Apr 13, 2010 at 4:27 PM, Jason F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> `require': 126: The specified module could not be found. - C:/Ruby19/lib/ruby/gems/1.9.1/gems/mongrel-1.1.5-x86-mingw32/lib/http11.so (LoadError) from C:/Ruby19/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `block in require’  
> from

The gem you have installed has been compiled for Ruby 1.8, not Ruby 1.9

You need a gem that is compatible with Ruby 1.9

At this time, I would recommend you install the pre-release version of  
the gem:

gem install mongrel --pre

Which includes binaries for 1.9

## HTH,

## Luis L. AREA 17

Perfection in design is achieved not when there is nothing more to add,  
but rather when there is nothing more to take away.  
Antoine de Saint-Exupéry

---

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [April 13, 2010, 11:04pm UTC](https://www.ruby-forum.com/t/problem-getting-mongrel-to-work-with-radrails/186888/3 "2010-04-13T23:04:00Z")

</div>

I need to pass some startup options on to my rails application. Using  
environment variables will not work because multiple mongrel clusters of  
my  
rails application (each of a slightly different flavour) served from a  
single code base can run concurrently and each cluster instance is  
activated  
via mongrel\_service.

Extra arguments passed in to either mongrel\_rails service::install or  
mongrel\_rails cause errors.

The only documentation on the --script option I could find related to  
unix  
so I gave up on that thought.

I also tried using the --config option, but I had the same problem  
there: as  
soon as I added an option to the YAML file that wasn’t documented,  
mongrel  
complained with an error.

The last one is a real nuisance. It just doesn’t make sense that my  
config  
file should be restricted to content mongrel understands. Wouldn’t it be  
a  
better approach to parse that file and look/apply the options mongrel  
recognises and provide a public interface so that other interested  
clients  
can access the config file?

Or are there other ways to achieve this without resorting to modifying  
mongrel and mongrel services startup code?

Pete

---

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [April 13, 2010, 11:41pm UTC](https://www.ruby-forum.com/t/problem-getting-mongrel-to-work-with-radrails/186888/4 "2010-04-13T23:41:28Z")

</div>

On Tue, Apr 13, 2010 at 5:34 PM, Pete [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I need to pass some startup options on to my rails application. Using  
> environment variables will not work because multiple mongrel clusters of my  
> rails application (each of a slightly different flavour) served from a  
> single code base can run concurrently and each cluster instance is activated  
> via mongrel\_service.
> 
> Extra arguments passed in to either mongrel\_rails service::install or  
> mongrel\_rails cause errors.

I think you’ve already reported this to me here:

[http://github.com/fauna/mongrel\_service/issues#issue/4](http://github.com/fauna/mongrel_service/issues#issue/4)

And if wasn’t you, pretty much is similar request.

> The only documentation on the --script option I could find related to unix  
> so I gave up on that thought.

Script takes any Ruby script and execute it before starting mongrel,  
and is honored by mongrel\_service

> I also tried using the --config option, but I had the same problem there: as  
> soon as I added an option to the YAML file that wasn’t documented, mongrel  
> complained with an error.

mongrel\_rails start --help:

```
-C, --config PATH Use a config file
-S, --script PATH Load the given file as an extra

```

config script  
-G, --generate PATH Generate a config file for use with  
-C

mongrel\_rails start -G foo.yml  
\*\* Writing config to “C:/Users/Luis/projects/secret/foo.yml”.  
\*\* Finished. Run “mongrel\_rails start -C  
C:/Users/Luis/projects/secret/foo.yml” to use the config file.

> The last one is a real nuisance. It just doesn’t make sense that my config  
> file should be restricted to content mongrel understands. Wouldn’t it be a  
> better approach to parse that file and look/apply the options mongrel  
> recognises and provide a public interface so that other interested clients  
> can access the config file?

Sorry, but is the configuration file _for_ mongrel, nobody says to you  
that you should use it.

The problem is that you’re trying to use the same application, the  
same checkout of it and everything to run multiple instances that are  
different on configuration settings.

Apologizes for this but that is wrong.

Even sharing database.yml could lead to problems.

> Or are there other ways to achieve this without resorting to modifying  
> mongrel and mongrel services startup code?

Do checkouts of your application on different directories. Have  
per-location configuration settings like config/settings.yml that is  
not part of your application source code.

Is kind of complicated expect the same application folder serve  
multiple versions of the same application. Perhaps if you would  
explain better what are those settings we can advise you on different  
approaches.

## – Luis L. AREA 17

Perfection in design is achieved not when there is nothing more to add,  
but rather when there is nothing more to take away.  
Antoine de Saint-Exupéry

---

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [April 14, 2010, 12:38am UTC](https://www.ruby-forum.com/t/problem-getting-mongrel-to-work-with-radrails/186888/5 "2010-04-14T00:38:15Z")

</div>

On Tue, Apr 13, 2010 at 7:25 PM, Pete [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> boot.rb

I would avoid script/server as it loads mongrel incorrectly.

> So clearly, running code (that fetches custom specific command line options)  
> before rails starts doesn’t work well with either environment, let alone  
> both.

Can I know how are you doing it?

> I’ve even tried to place such code inside environment.rb which is clearly  
> loaded before application.rb and still had no luck.

Which part? the top? the bottom? Which version of rails?

If you place the code in config/preinitializer.rb it will be loaded  
before environment.rb fully loads.

> So far, the only way that worked for me is to modify library code and this  
> is something a dread.

Please be more specific with the examples. Show us code so we can  
replicate and workout solutions.

You can’t supply command line options to mongrel\_rails that are not  
supported, however, you can use either environment variables or other  
stuff.

## – Luis L. AREA 17

Perfection in design is achieved not when there is nothing more to add,  
but rather when there is nothing more to take away.  
Antoine de Saint-Exupéry

---

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [April 14, 2010, 1:43am UTC](https://www.ruby-forum.com/t/problem-getting-mongrel-to-work-with-radrails/186888/6 "2010-04-14T01:43:50Z")

</div>

Hi Luis,

Thanks for your reply.

You’re right, it was me who ask the same question in github, but since  
it  
was more related to mongrel\_service and my issue has to do with rails  
boot  
strapping it didn’t seem the right place.

First up, I’m still using Rails 2.2.2.

I’m sorry, but I don’t agree with you that a single code base for  
multiple  
different rails application is a bad idea, quite the opposite actually.  
If  
you’re really interested in what we’re doing, this thread explains it in  
more detail: [http://railsforum.com/viewtopic.php?pid=74217](http://railsforum.com/viewtopic.php?pid=74217).

It shouldn’t be too hard to see the many advantages of a single code  
base  
over multiple code bases for serving multiple clients similar  
applications.

As I said, I played with the --script option but couldn’t get it to  
work.  
Here is how I start mongrel from the command line for client FOO:

mongrel\_rails start -e production -p 3035 -l “log/FOO/mongrel.log” -S  
“config/FOO/myapp\_opts.rb” -c “x:/myapp”

But config/FOO/myapp\_opts.rb is never loaded (I’ve also tried specifying  
the  
full path “x:/myapp/config/FOO/myapp\_opts.rb” to no avail). If this  
worked,  
it would solve my problem. So what am I doing wrong?

Pete

---

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [April 14, 2010, 12:29am UTC](https://www.ruby-forum.com/t/problem-getting-mongrel-to-work-with-radrails/186888/7 "2010-04-14T00:29:28Z")

</div>

Interesting is also this page [http://guides.rails.info/configuring.html](http://guides.rails.info/configuring.html)  
which states under “2.Running Code Before Rails”: To run some code  
before  
Rails itself is loaded, simply put it above the call to require  
‘rails/all’  
in your application.rb.

If I log boot strapping of rails, I get this different sequences:

when using mongrel via script/server (notice boot.rb appears twice!!!):  
boot.rb  
environment.rb  
boot.rb  
application.rb

when using mongrel via mongrel\_rails:  
environment.rb  
boot.rb  
application.rb

Note that while the latter option is the common way to start the  
application, the former option is what I must use to debug my rails  
application under Netbeans.

So clearly, running code (that fetches custom specific command line  
options)  
before rails starts doesn’t work well with either environment, let alone  
both.

I’ve even tried to place such code inside environment.rb which is  
clearly  
loaded before application.rb and still had no luck.

So far, the only way that worked for me is to modify library code and  
this  
is something a dread.

Pete

---

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [April 14, 2010, 3:59am UTC](https://www.ruby-forum.com/t/problem-getting-mongrel-to-work-with-radrails/186888/8 "2010-04-14T03:59:05Z")

</div>

Hi Luis,

> You’re preaching to the wrong choir.

I’m glad 😉

> \*\* Rails loaded.  
> \*\* Loading any Rails specific GemPlugins
> 
> (dunno why appears twice, is like the file gets “loaded” instead of  
> required)

* * *

\*\*\* WOW!!! \*\*\*

* * *

I had no idea that would work. What are these things called? They’re not  
really options, are they?

Just tried it out and not only can I trap these options easily using  
preinitialize.rb with mongrel\_service as well as mongrel\_rails, but it  
also  
works perfectly fine in script/server (sorry, I know you don’t like this  
and  
I trust your judgement, but it is the only option I have when debugging  
under Netbeans).

THIS SOLVES MY PROBLEM!

I missed this feature completely or it is undocumented. Had I known that  
a  
couple of weeks back I could have spent a week at the beach and would  
still  
be further than I am now.

> 1. Add the additional parameter to created mongrel\_service manually  
> (registry editing)

For me that isn’t a big deal since we have an installer and can easily  
configure the mongrel services during installation by writing to the  
registry directly.

> Thank you for explaining in further detail your need, it helped me  
> provide you a better alternative. Of course, there is still room for  
> improvement, and patches are always welcomed 😉

NO THANK YOU FOR YOUR HELP!

Now I’ve also noticed that mongrel\_rails service::install doesn’t  
complain  
at all if I specify such glyphs (like MYAPP\_TARGET=foo). However, they  
are  
not added to the ImagePath. If you think this would be useful, I see if  
I  
can fix it and submit a patch?

Many thanks again, its hugely appreciated.

---

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [April 14, 2010, 4:15am UTC](https://www.ruby-forum.com/t/problem-getting-mongrel-to-work-with-radrails/186888/9 "2010-04-14T04:15:29Z")

</div>

On Tue, Apr 13, 2010 at 10:49 PM, Pete [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > [“MYAPP\_TARGET =foo”]  
> > I had no idea that would work. What are these things called? They’re not  
> > really options, are they?

They are coming from ARGV, are not parsed by OptionParse (used by  
mongrel), so are just ignored and left available in ARGV.

> Just tried it out and not only can I trap these options easily using  
> preinitialize.rb with mongrel\_service as well as mongrel\_rails, but it also  
> works perfectly fine in script/server (sorry, I know you don’t like this and  
> I trust your judgement, but it is the only option I have when debugging  
> under Netbeans).

Hehe, well, if works for you for debugging will not say anything 🙂

> THIS SOLVES MY PROBLEM!

Glad to hear that.

> I missed this feature completely or it is undocumented. Had I known that a  
> couple of weeks back I could have spent a week at the beach and would still  
> be further than I am now.

config/preinitializer.rb is a hidden feature that actually nobody  
knows of it. It started to be more noticeable with the appearance of  
Bundler.

Apologizes for you spending your time doing this, the mailing list  
should have been more exposed ☹

> Now I’ve also noticed that mongrel\_rails service::install doesn’t complain  
> at all if I specify such glyphs (like MYAPP\_TARGET=foo). However, they are  
> not added to the ImagePath. If you think this would be useful, I see if I  
> can fix it and submit a patch?

These options are not carried over. A minor patch that takes the left  
overs of ARGV and append to the registry line could work.

Add the gist link with the diff to the mongrel\_service GitHub issue,  
I’ll get that integrated 😉

> Many thanks again, its hugely appreciated.

You’re welcome 🙂

## Regards,

## Luis L. AREA 17

Perfection in design is achieved not when there is nothing more to add,  
but rather when there is nothing more to take away.  
Antoine de Saint-Exupéry

---

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [April 14, 2010, 2:30am UTC](https://www.ruby-forum.com/t/problem-getting-mongrel-to-work-with-radrails/186888/10 "2010-04-14T02:30:06Z")

</div>

On Tue, Apr 13, 2010 at 8:39 PM, Pete [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi Luis,
> 
> First up, I’m still using Rails 2.2.2.
> 
> I’m sorry, but I don’t agree with you that a single code base for multiple  
> different rails application is a bad idea, quite the opposite actually. If  
> you’re really interested in what we’re doing, this thread explains it in  
> more detail: [http://railsforum.com/viewtopic.php?pid=74217](http://railsforum.com/viewtopic.php?pid=74217).

You’re preaching to the wrong choir.

I was the one that originated the approach of Radiant to build  
applications, and make gems of Rails applications with custom  
settings, database and configuration files. It was called fossilize,  
but due the constant internal changes of Rails was hard to keep it up.

Since now is based on Rack (Rails 3), it might be easy to resurrect the  
idea.

> It shouldn’t be too hard to see the many advantages of a single code base  
> over multiple code bases for serving multiple clients similar applications.

Is not that is hard to see, is hard to wrap Rails around that concept

Reading your post what you actually need is more in the lines of  
Radiant approach:

- make your application a gem
- use a single directory for each individual application, but still  
depend on the same gem
- extend or change the application with extensions from vendor, that  
might be different from client A to client B

> As I said, I played with the --script option but couldn’t get it to work.  
> Here is how I start mongrel from the command line for client FOO:
> 
> mongrel\_rails start -e production -p 3035 -l “log/FOO/mongrel.log” -S  
> “config/FOO/myapp\_opts.rb” -c “x:/myapp”
> 
> But config/FOO/myapp\_opts.rb is never loaded (I’ve also tried specifying the  
> full path “x:/myapp/config/FOO/myapp\_opts.rb” to no avail). If this worked,  
> it would solve my problem. So what am I doing wrong?

According to this:

[http://github.com/fauna/mongrel/blob/master/bin/mongrel\_rails#L122-125](http://github.com/fauna/mongrel/blob/master/bin/mongrel_rails#L122-125)

And this:

[http://github.com/fauna/mongrel/blob/master/lib/mongrel/configurator.rb#L342-348](http://github.com/fauna/mongrel/blob/master/lib/mongrel/configurator.rb#L342-348)

The purpose of the config script is internal of Mongrel, not to setup  
stuff globally for the application like Rails.

\*\* Starting Mongrel listening at 0.0.0.0:3000  
\*\* Starting Rails with development environment…  
\*\* Rails loaded.  
\*\* Loading any Rails specific GemPlugins  
\*\* Loading config/init\_mongrel.rb external config script

Also, it happens “after” Rails initialization.

I would suggest you try the following:

1. put your init script code inside config/preinitializer.rb

It gets executed by boot before Rails::Initializer.run of  
environment.rb.

example:

> type config\preinitializer.rb  
> STDERR.puts ARGV.inspect

1. Use something like MYAPP\_TARGET=foo in the command line:

mongrel\_rails start MYAPP\_TARGET=foo

Will get you something like this:

\*\* Starting Mongrel listening at 0.0.0.0:3000  
\*\* Starting Rails with development environment…  
[“MYAPP\_TARGET =foo”]  
[“MYAPP\_TARGET =foo”]  
\*\* Rails loaded.  
\*\* Loading any Rails specific GemPlugins

(dunno why appears twice, is like the file gets “loaded” instead of  
required)

1. Add the additional parameter to created mongrel\_service manually  
(registry editing)

At this time, there is no way to specify additional parameters. I  
would like to move the configuration from command line to the  
registry, so is more easy to manipulate.

That helps somehow?

Thank you for explaining in further detail your need, it helped me  
provide you a better alternative. Of course, there is still room for  
improvement, and patches are always welcomed 😉

## – Luis L. AREA 17

Perfection in design is achieved not when there is nothing more to add,  
but rather when there is nothing more to take away.  
Antoine de Saint-Exupéry

---

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [April 14, 2010, 8:04am UTC](https://www.ruby-forum.com/t/problem-getting-mongrel-to-work-with-radrails/186888/11 "2010-04-14T08:04:19Z")

</div>

> > If I can fix it and submit a patch…
> 
> Add the gist link with the diff to the mongrel\_service GitHub issue,  
> I’ll get that integrated 😉

I wish I knew anything about gist, but I made a simple change to  
mongrel\_service-0.4.beta3\lib\mongrel\_service\init.rb which I explained  
here: [http://github.com/fauna/mongrel\_service/issues/#issue/4](http://github.com/fauna/mongrel_service/issues/#issue/4)

The modified file is enclosed.

Cheers and thanks heaps  
Pete
