# "service mongrel\_cluster start" startup fails

**URL:** <https://www.ruby-forum.com/t/service-mongrel-cluster-start-startup-fails/148567>\
**Category:** Mongrel\
**Created:** [September 15, 2008, 4:44am UTC](https://www.ruby-forum.com/t/service-mongrel-cluster-start-startup-fails/148567 "2008-09-15T04:44:26Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sjmadsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b3f665/32.png) [@sjmadsen](https://www.ruby-forum.com/u/sjmadsen)\
**Post date:** [September 15, 2008, 4:44am UTC](https://www.ruby-forum.com/t/service-mongrel-cluster-start-startup-fails/148567/1 "2008-09-15T04:44:26Z")

</div>

I’ve attempted to configure mongrel to start as a service in RHEL.  
I’ve copied mongrel\_cluster to /etc/init.d and  
“#/etc/init.d/mongrel\_cluster start” does work. However when I attempt  
to start mongrel\_cluster using “service mongrel\_cluster start” I get the  
following error:  
service mongrel\_cluster start  
/usr/bin/env: ruby: No such file or directory

I am somewhat new to ruby. But could sure use some help.

chkconfig --level 35 mongrel\_cluster on

# chkconfig --list mongrel\_cluster

mongrel\_cluster 0:off 1:off 2:off 3:on 4:off 5:on 6:off

---

<div class="post-metadata">

**Author:** ![sjmadsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b3f665/32.png) [@sjmadsen](https://www.ruby-forum.com/u/sjmadsen)\
**Post date:** [September 15, 2008, 2:13pm UTC](https://www.ruby-forum.com/t/service-mongrel-cluster-start-startup-fails/148567/2 "2008-09-15T14:13:56Z")

</div>

On Mon, Sep 15, 2008 at 4:44 AM, Steve M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I’ve attempted to configure mongrel to start as a service in RHEL.  
> I’ve copied mongrel\_cluster to /etc/init.d and  
> “#/etc/init.d/mongrel\_cluster start” does work. However when I attempt  
> to start mongrel\_cluster using “service mongrel\_cluster start” I get the  
> following error:  
> service mongrel\_cluster start  
> /usr/bin/env: ruby: No such file or directory

“service” gives a better picture of what will happen on boot since it  
sets  
up the environment as it would be for the init process that runs all the  
little start scripts. In this case, it looks like ruby is not in the  
default path. Read the man-page for ‘service’ for a little more  
information  
and try creating a simple script in /etc/init.d that just prints out the  
environment variables, like this (untested):

---------------8\<--------  
#! /bin/sh  
env  
-------------8\<---------

Make it executable and run it with “service name\_of\_script start” to see  
what it prints. It’s not the solution to your problem, but it’s a  
start.

/David

---

<div class="post-metadata">

**Author:** ![sjmadsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b3f665/32.png) [@sjmadsen](https://www.ruby-forum.com/u/sjmadsen)\
**Post date:** [December 13, 2008, 4:27am UTC](https://www.ruby-forum.com/t/service-mongrel-cluster-start-startup-fails/148567/3 "2008-12-13T04:27:51Z")

</div>

David V. wrote:

> On Mon, Sep 15, 2008 at 4:44 AM, Steve M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > I’ve attempted to configure mongrel to start as a service in RHEL.  
> > I’ve copied mongrel\_cluster to /etc/init.d and  
> > “#/etc/init.d/mongrel\_cluster start” does work. However when I attempt  
> > to start mongrel\_cluster using “service mongrel\_cluster start” I get the  
> > following error:  
> > service mongrel\_cluster start  
> > /usr/bin/env: ruby: No such file or directory
> 
> “service” gives a better picture of what will happen on boot since it  
> sets  
> up the environment as it would be for the init process that runs all the  
> little start scripts. In this case, it looks like ruby is not in the  
> default path. Read the man-page for ‘service’ for a little more  
> information  
> and try creating a simple script in /etc/init.d that just prints out the  
> environment variables, like this (untested):
> 
> ---------------8\<--------  
> #! /bin/sh  
> env  
> -------------8\<---------
> 
> Make it executable and run it with “service name\_of\_script start” to see  
> what it prints. It’s not the solution to your problem, but it’s a  
> start.
> 
> /David

I did get past this but now the “service mongrel\_cluster” fails with the  
following; (i’ve added the env command to the script)  
service mongrel\_cluster start  
TERM=xterm  
PATH=/sbin:/usr/sbin:/bin:/usr/bin  
PWD=/  
LANG=en\_US.UTF-8  
SHLVL=1  
\_=/bin/env  
/usr/bin/mongrel\_cluster\_ctl:9:in `require’: no such file to load –  
rubygems (LoadError)  
from /usr/bin/mongrel\_cluster\_ctl:9

While /init.d/mongrel\_cluster start works and the env info is;  
SHELL=/bin/bash  
TERM=xterm  
HISTSIZE=1000  
USER=sfcapp  
LS\_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:_.cmd=00;32:_.exe=00;32:_.com=00;32:_.btm=00;32:_.bat=00;32:_.sh=00;32:_.csh=00;32:_.tar=00;31:_.tgz=00;31:_.arj=00;31:_.taz=00;31:_.lzh=00;31:_.zip=00;31:_.z=00;31:_.Z=00;31:_.gz=00;31:_.bz2=00;31:_.bz=00;31:_.tz=00;31:_.rpm=00;31:_.cpio=00;31:_.jpg=00;35:_.gif=00;35:_.bmp=00;35:_.xbm=00;35:_.xpm=00;35:_.png=00;35:_.tif=00;35:  
PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin  
MAIL=/var/spool/mail/root  
PWD=/etc/init.d  
INPUTRC=/etc/inputrc  
LANG=en\_US.UTF-8  
SSH\_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass  
HOME=/root  
SHLVL=2  
LOGNAME=root  
CVS\_RSH=ssh  
SSH\_CONNECTION=9.65.247.187 3708 9.54.168.71 22  
LESSOPEN=|/usr/bin/lesspipe.sh %s  
G\_BROKEN\_FILENAMES=1  
\_=/bin/env

I have tried adding /usr/local/bin to the path; didn’t work

---

<div class="post-metadata">

**Author:** ![sjmadsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b3f665/32.png) [@sjmadsen](https://www.ruby-forum.com/u/sjmadsen)\
**Post date:** [December 15, 2008, 12:42am UTC](https://www.ruby-forum.com/t/service-mongrel-cluster-start-startup-fails/148567/4 "2008-12-15T00:42:47Z")

</div>

On Sat, Dec 13, 2008 at 04:30, Steve M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Steve M. wrote:
> 
> If you have the mongrel\_cluster working on a linux box; could you print  
> out the result of the env command as you have it?

[root@blade init.d]# service envtest start  
TERM=xterm-color  
PATH=/sbin:/usr/sbin:/bin:/usr/bin  
PWD=/  
LANG=en\_US.UTF-8  
SHLVL=1  
\_=/bin/env

and, not unimportantly:

[root@blade init.d]# which ruby  
/usr/bin/ruby

/David

---

<div class="post-metadata">

**Author:** ![sjmadsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b3f665/32.png) [@sjmadsen](https://www.ruby-forum.com/u/sjmadsen)\
**Post date:** [December 15, 2008, 12:48am UTC](https://www.ruby-forum.com/t/service-mongrel-cluster-start-startup-fails/148567/5 "2008-12-15T00:48:39Z")

</div>

On Sat, Dec 13, 2008 at 04:27, Steve M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> /usr/bin/mongrel\_cluster\_ctl:9:in `require’: no such file to load –  
> […] I have tried adding /usr/local/bin to the path; didn’t work

Let me be clear on this… did you add /usr/local/bin to the path in  
such a  
way that ‘service mongrel\_cluster start’ showed PATH=/usr/local/bin:…,  
but  
the cluster did still not start? Or do you mean that you didn’t succeed  
in  
adding /usr/local/bin to the path? Or something else?

Seeing as three months have gone and we’re now in a different era, you  
could  
have a go at setting up apache with mod\_rails instead. The time might  
be  
better spent there; I understand that mod\_rails (Fusion passenger) is a  
nice  
experience.

Good luck!

/David

---

<div class="post-metadata">

**Author:** ![sjmadsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b3f665/32.png) [@sjmadsen](https://www.ruby-forum.com/u/sjmadsen)\
**Post date:** [December 13, 2008, 4:30am UTC](https://www.ruby-forum.com/t/service-mongrel-cluster-start-startup-fails/148567/6 "2008-12-13T04:30:01Z")

</div>

Steve M. wrote:

If you have the mongrel\_cluster working on a linux box; could you print  
out the result of the env command as you have it?

---

<div class="post-metadata">

**Author:** ![sjmadsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b3f665/32.png) [@sjmadsen](https://www.ruby-forum.com/u/sjmadsen)\
**Post date:** [December 17, 2008, 7:20am UTC](https://www.ruby-forum.com/t/service-mongrel-cluster-start-startup-fails/148567/7 "2008-12-17T07:20:25Z")

</div>

I did add /usr/local/bin to the path in the mongrel\_cluster file and I  
still had issues; these were other ruby issues.  
What I ended up doing was creating a custom file to do the start and  
stop. That worked and I did have to add /usr/local/bin to the path.

I’ve pasted in the file I created; I am sure there are issues with it.  
But it works…

Thanks for your help the path suggestion was key to my getting this to  
work.

#!/bin/sh  
###########################################################################

# chkconfig: - 85 35

# description: Mongrel Rails appserver

# processname: mongrel\_rails

# config: /home/sfcapp/sfc/current/config/mongrel\_cluster.yml

# 

export PATH=$PATH:/usr/local/bin  
export SFCAPPHOME="/home/sfcapp/sfc"  
export CURRENT\_DIR="$SFCAPPHOME/current/config"  
export MONGREL\_RAILS="/usr/local/bin/mongrel\_rails"  
echo $SFCAPPHOME $CURRENT\_DIR $MONGREL\_RAILS

case “$1” in start)  
/usr/local/bin/mongrel\_rails cluster::start -C  
/home/sfcapp/sfc/current/config/  
mongrel\_cluster.yml  
;;  
stop)  
/usr/local/bin/mongrel\_rails cluster::stop -C  
/home/sfcapp/sfc/current/config/m  
ongrel\_cluster.yml  
;;  
restart)  
/usr/local/bin/mongrel\_rails cluster::stop -C  
/home/sfcapp/sfc/current/config/mongrel\_cluster.yml  
/usr/local/bin/mongrel\_rails cluster::start -C  
/home/sfcapp/sfc/current/config/mongrel\_cluster.yml  
;;  
\*)  
echo “usage start | stop | restart”  
;;  
esac

---

<div class="post-metadata">

**Author:** ![sjmadsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b3f665/32.png) [@sjmadsen](https://www.ruby-forum.com/u/sjmadsen)\
**Post date:** [February 20, 2009, 12:49am UTC](https://www.ruby-forum.com/t/service-mongrel-cluster-start-startup-fails/148567/8 "2009-02-20T00:49:03Z")

</div>

Hi all,

Im having the same problem as Steve M. was and still hope to find out  
what was wrong rather then writing a custom file as he ended up doing.  
I very much appreciate any insight you can provide!

Same Problem:  
My rails application runs great, but it needs to be started manually. I  
need it to restart when the machine restarts.

More explicitly,  
If I manually run

> /etc/init.d/mongrel\_cluster status  
> Then everything runs great.

But if i run

> service mongrel\_cluster status  
> Then I get the error:  
> /usr/bin/mongrel\_cluster\_ctl:9:in `require’: no such file to load –  
> rubygems (LoadError)

That line in mongrel\_cluster\_ctl is just:  
require ‘rubygems’

* * *

What have I done to anger the gods??

Some details on my system - perhaps i installed something in wrong  
place?  
ruby: /usr/bin/ruby  
rubygems: /usr/local/rubygems

* * *

I am new to linux - can someone help me with that line “require  
‘rubygems’”…  
What does ‘require’ mean in a shell script - i found no man page. What  
should it actually find, a file? I have the directory  
“/usr/local/rubygems” is that what it is looking for? Or should it find  
an actual file called ‘rubygems’ somewhere?

By the way, in the /etc/init.d/mongrel\_cluster I did expand the path  
with:  
export PATH=/usr/local:/usr/local/bin:$PATH

And that script then echos the path when run with service command as:  
/usr/local:/usr/local/bin:/sbin:/usr/sbin:/usr/bin

* * *

Thanks for reading!

Topher

---

<div class="post-metadata">

**Author:** ![sjmadsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b3f665/32.png) [@sjmadsen](https://www.ruby-forum.com/u/sjmadsen)\
**Post date:** [January 11, 2009, 4:52am UTC](https://www.ruby-forum.com/t/service-mongrel-cluster-start-startup-fails/148567/9 "2009-01-11T04:52:00Z")

</div>

All,

> /usr/bin/mongrel\_cluster\_ctl:9:in `require’: no such file to load –  
> […] I have tried adding /usr/local/bin to the path; didn’t work

A similar thing happened to me when I was testing a Ruby-based startup  
(/etc/init.d) script and was getting failures on my “load” command  
(similar symptoms to David’s failure on “require”.

I looked at the failure using strace and noticed that the final library  
lookup for say xxx.rb would be ./xxx.rb. This made me wonder what the  
current working directory was and it seems that scripts started with  
/sbin/service are started in the directory “/”. So unless your loaded or  
required script is in “/” it will fail. Here is what the contents of var  
$: look like on my machine that seem to confirm this (this is the load  
order):

/usr/lib/ruby/site\_ruby/1.8  
/usr/lib/ruby/site\_ruby/1.8/i386-linux  
/usr/lib/ruby/site\_ruby  
/usr/lib/site\_ruby/1.8  
/usr/lib/site\_ruby/1.8/i386-linux  
/usr/lib/site\_ruby  
/usr/lib/ruby/1.8  
/usr/lib/ruby/1.8/i386-linux  
.

Notice that “.” (current dir is the last one). I tried adding  
/etc/init.d (where my other scripts were for startup) using:  
$:.unshift(“/etc/init.d”) to dynamically change the search order and  
ended up with this, which worked:

/etc/init.d  
/usr/lib/ruby/site\_ruby/1.8  
/usr/lib/ruby/site\_ruby/1.8/i386-linux  
/usr/lib/ruby/site\_ruby  
/usr/lib/site\_ruby/1.8  
/usr/lib/site\_ruby/1.8/i386-linux  
/usr/lib/site\_ruby  
/usr/lib/ruby/1.8  
/usr/lib/ruby/1.8/i386-linux  
.

Now I can keep the whole thing Ruby-based without having to change the  
/sbin/service code or resort to bash startup scripts to kick things  
off…

The section entitled “Where Ruby Finds Its Modules” in the Programming  
Ruby book ([Programming Ruby: The Pragmatic Programmer's Guide](http://www.ruby-doc.org/docs/ProgrammingRuby/)) was helpful to  
me in understanding this.

Hope this helps the next victim.
