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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4a9cd711ccb80f1ab3ce17450c2857e4?d=identicon&s=25 Greg Willits (-gw-)
on 2009-04-13 08:21
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:
/ImageMagick-6.5.0/lib/libMagickCore.2.dylib"

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.

--gw

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/"
end

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

end

p MagickImage.new("/Users/greg/Desktop/goodfood.jpg").width
4a9cd711ccb80f1ab3ce17450c2857e4?d=identicon&s=25 Greg Willits (-gw-)
on 2009-04-13 08:54
Greg Willits wrote:
> 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).
> 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:
> /ImageMagick-6.5.0/lib/libMagickCore.2.dylib"

aarrrgggghhhhh.

Stupid IM binaries require a symlink at the root of the startupdrive.
*lame!*

-- gw
This topic is locked and can not be replied to.