问题
I have installed RMagick on OSX via MacPorts and can see it by running 'gem server'. However when I try to include it in my script using
require 'rubygems'
require 'RMagick'
It crashes with the following error message
./RMagick.rb:4:in `show_info': uninitialized constant Magick (NameError)
from ./RMagick.rb:24
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from ./rmagick.rb:1
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from get_pixels.rb:2
Could anyone tell me what I'm doing wrong?
回答1:
I have once created an ImageResize Tool and I just checked how I've included it there:
require 'rubygems'
require 'RMagick'
include Magick
I have also OS X and installed the RMagick with macports. Maybe you need also to include the Module Magick. But I'm not sure.
Some more code from your RMagick.rb would maybe help to detect the problem..
来源:https://stackoverflow.com/questions/2662977/require-rmagick-not-working