shell cmd fails from Rails (not from CLI & Ruby script)

Rails 2.3.2, OS X 10.5.6

I am using the backtick method to run a shell command (happens to be
ImageMagick stuff). The command works fine when I use it directly in
Terminal. The command work fine if I extract the code out of Rails and
put it into a text.rb file. From inside a Rails app it fails.

I'm still trying to understand the nature of the failure, but if I use
2>&1 at the end of the command, I can log an error message:
  "dyld: Library not loaded:

Googling not helping with that one, but I have checked that the file
does exist, and AFAICT my profile file has the correct info re: the
paths. And, there's the thing that the command actually works from CLI
and a plain Ruby script.

I have logged everything I can think of. I have even hard coded the
entire shell command inside the Rails app.

Just can't figure out why the difference when the code is run inside a
Rails app.

Any ideas?? Thanks.


The test code....

#!/usr/bin/env ruby

class MagickImage

def initialize(real_image_path)
  @real_file_path = real_image_path
  @magick_bin = "/usr/local/ImageMagick/bin/"

def width
  img_width = ""
  if @real_file_path && FileTest.exists?(@real_file_path)
    img_width = `#{@magick_bin}/identify -format "%w"
    img_width.strip! unless img_width.nil?
    img_width = "" if img_width.nil?
  return img_width