Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am booting using a machine using chef. I need it to install a init.d script which it does and when the script is invoked at the end of chef run the script fails on the require 'daemons' line (shown below). I have a print before and after the require and the one before the require is logged.

# my_invoked_script.rb
 pid = fork
 if pid.nil?
     puts "Before"
     require 'daemons'
     puts "After"

The before print is logged. The after print is not. I am thinking since this is at boot time some env variables may not be set right. Has anyone been able to run ruby scripts with a require in them at boot time?

My init.d script is a standard script with start function as follows:

   /usr/local/bin/ruby /home/ubuntu/my_invoked_script.rb

Logging into terminal and running the script shows no error and things proceed as normal.

Ruby 1.9.2 ubuntu 11.04 though I am not sure either of them are the issue here.

share|improve this question

It could be environment variables, or it could be that the file system with the modules isn't mounted at the time when the script is run.

You could try running with ruby -w to get more information, or you could set the RUBYLIBS environemnt variable before running the ruby script, e.g.

export RUBYLIB="/path/to/lib/ruby"

at the start.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.