Script acting differently inside of rake task

I’ve created a rake task that does various things, one of which is
calling a script. When I call that script from my Rails.root folder,
it works, but it doesn’t work inside my rake task. [This is rails 3]

That is, the following line works from bash:

lib/daemons/mailer_ctl start

However, inside my rake task, this line does not work:

puts lib/daemons/mailer_ctl start

The error message is:

lib/daemons/mailer_ctl:3:in `require’: no such file to load – daemons
(LoadError)
from lib/daemons/mailer_ctl:3

So, it can’t be a problem with the current working directory, because
it found the file to execute.

The daemon is very typical. The first few lines are:

#!/usr/bin/env ruby
require ‘rubygems’
require “daemons”
require ‘yaml’
require ‘erb’

So, the require for rubygems must have succeeded, since it failed on
the require for daemons.

Why does it work from the command line, but not from the rake task?

Thanks,

On Oct 6, 7:51 pm, Paul [email protected] wrote:

So, the require for rubygems must have succeeded, since it failed on
the require for daemons.

Why does it work from the command line, but not from the rake task?

Check the environment used by `` - could it be picking up a different
$PATH (and thus a different ruby install) ?

Fred

Check the environment used by `` - could it be picking up a different
$PATH (and thus a different ruby install) ?

Fred

Well, that’s odd, too. If I put:

puts set

in my rake file, it gives me the error:

/usr/local/lib/ruby/gems/1.8/gems/railties-3.0.0/lib/rails/application.rb:103:
command not found: set

Which doesn’t make sense to me at all.

Anyway, ruby -v gives the same version from the command line as from
the rake file, and this computer only has one version of ruby anyway,
so I figured it would.

Any other ideas? Or any workarounds?

SOLVED:

I needed:

gem ‘daemons’

in my Gemfile.

When I ran it from the command line, it doesn’t go through bundler,
but evidently, even though I’m supposedly just spawning a separate
process, it magically is.