Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Ruby can't see RMagick installed from gem on FC4

19 views
Skip to first unread message

Lance Squire

unread,
Aug 2, 2006, 10:40:30 AM8/2/06
to
I'm planning on using RMagick to do thumbnails for a Rails project.

Installed RMagick using 'gem install rmagick'

Here are last few lines...
--------------------------------------------------------------------------
gcc -fPIC -Wall -g -I. -I/usr/lib/ruby/1.8/i386-linux
-I/usr/lib/ruby/1.8/i386-linux
-I/usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/ext/RMagick
-DRUBY_VERSION=0x184 -I/usr/include -c rmfill.c
gcc -fPIC -Wall -g -I. -I/usr/lib/ruby/1.8/i386-linux
-I/usr/lib/ruby/1.8/i386-linux
-I/usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/ext/RMagick
-DRUBY_VERSION=0x184 -I/usr/include -c rminfo.c
gcc -fPIC -Wall -g -I. -I/usr/lib/ruby/1.8/i386-linux
-I/usr/lib/ruby/1.8/i386-linux
-I/usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/ext/RMagick
-DRUBY_VERSION=0x184 -I/usr/include -c rmmain.c
gcc -shared -L/usr/lib -lfreetype -lz -L/usr/lib -L"/usr/lib" -o
RMagick.so rmilist.o rmdraw.o rmutil.o rmimage.o rmfill.o rminfo.o
rmmain.o -lMagick -llcms -ltiff -lfreetype -ljpeg -lgs -lXext -lSM -lICE
-lX11 -lXt -lbz2 -lz -lpthread -lm -lpthread -lruby -ldl -lcrypt -lm
-lc
make[1]: Leaving directory
`/usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/ext/RMagick'
setup.rb: entering post-setup phase...
post-setup.rb: setting up documentation...
/usr/bin/ruby -I /usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/./lib -I
/usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/./ext/RMagick Adispatch.rb
/usr/bin/ruby -I /usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/./lib -I
/usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/./ext/RMagick
InitialCoords.rb
post-setup.rb: InitialCoords.rb example returned error code 256
/usr/bin/ruby -I /usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/./lib -I
/usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/./ext/RMagick NewCoordSys.rb
post-setup.rb: NewCoordSys.rb example returned error code 256
/usr/bin/ruby -I /usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/./lib -I
/usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/./ext/RMagick OrigCoordSys.rb
post-setup.rb: OrigCoordSys.rb example returned error code 256
/usr/bin/ruby -I /usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/./lib -I
/usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/./ext/RMagick
PreserveAspectRatio.rb
post-setup.rb: PreserveAspectRatio.rb example returned error code 256
/usr/bin/ruby -I /usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/./lib -I
/usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/./ext/RMagick RotateScale.rb
post-setup.rb: RotateScale.rb example returned error code 256

make install
/usr/bin/ruby setup.rb install

post-install.rb: installing documentation...
Successfully installed rmagick-1.13.0
------------------------------------------------------------------------

'post-setup.rb' error codes worry me...

Tried using it anyway as installation reported as 'successful' anyway.

Rails complained about not finding the methods.

tried testing the "require 'RMagick'" in irb.

------
LoadError: no such file to load -- RMagick
from (irb):1:in `require'
from (irb):1
------

tried the sample script from the 'Users Guide'
------
require 'RMagick'
include Magick

cat = ImageList.new("Cheetah.jpg")
cat.display
exit
-------

Results:
-------
Rmagicktest.rb:1:in `require': no such file to load -- RMagick
(LoadError)
from Rmagicktest.rb:1
-------

Checked locations of Rmagick.so and libMagick.so

-------
locate RMagick.so
/usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/ext/RMagick/RMagick.so
/usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/lib/RMagick.so
locate libMagick.so
/usr/lib/libMagick.so
/usr/lib/libMagick.so.9
/usr/lib/libMagick.so.9.0.4
-------

No 'usr/local/lib/ to worry about...

Any ideas on where to look/ how to fix?

Thanks,

Lance F. Squire

--
Posted via http://www.ruby-forum.com/.

Justin Collins

unread,
Aug 2, 2006, 1:19:03 PM8/2/06
to
Lance Squire wrote:
> I'm planning on using RMagick to do thumbnails for a Rails project.
>
> Installed RMagick using 'gem install rmagick'
>
>
>
<snip lots of stuff>

> Results:
> -------
> Rmagicktest.rb:1:in `require': no such file to load -- RMagick
> (LoadError)
> from Rmagicktest.rb:1
> -------
>
> Checked locations of Rmagick.so and libMagick.so
>
> -------
> locate RMagick.so
> /usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/ext/RMagick/RMagick.so
> /usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/lib/RMagick.so
> locate libMagick.so
> /usr/lib/libMagick.so
> /usr/lib/libMagick.so.9
> /usr/lib/libMagick.so.9.0.4
> -------
>
> No 'usr/local/lib/ to worry about...
>
> Any ideas on where to look/ how to fix?
>
> Thanks,
>
> Lance F. Squire
>

If you are using a library installed with gems, you will need to

require 'rubygems'

first. Give that a try.

-Justin

Anatol Pomozov

unread,
Aug 2, 2006, 3:27:35 PM8/2/06
to

Try to run following line
ruby -rrubygems -e "require 'RMagick'; puts Magick::Long_version;"
what do you see??

Also you could read this article - you could find some interesting
things about RMagick

http://blog.pomozov.info/posts/adventure-with-rmagick-and-mongrel.html

Lance Squire

unread,
Aug 2, 2006, 3:34:31 PM8/2/06
to
Anatol Pomozov wrote:

> Try to run following line
> ruby -rrubygems -e "require 'RMagick'; puts Magick::Long_version;"
> what do you see??
>
> Also you could read this article - you could find some interesting
> things about RMagick
>
> http://blog.pomozov.info/posts/adventure-with-rmagick-and-mongrel.html

$ ruby -rrubygems -e "require 'RMagick'; puts Magick::Long_version;"
This is RMagick 1.13.0 ($Date: 2006/06/26 23:32:37 $) Copyright (C) 2006
by Timothy P. Hunter
Built with ImageMagick 6.2.5 05/25/06 Q16
file:/usr/share/ImageMagick-6.2.5/doc/index.html
Built for ruby 1.8.4 (2005-12-24) [i386-linux]
Web page: http://rmagick.rubyforge.org
Email: rma...@rubyforge.org

--------
Interesting.... That seems to work....

Reading website...

Lance Squire

unread,
Aug 2, 2006, 3:52:30 PM8/2/06
to
Anatol Pomozov wrote:

> Also you could read this article - you could find some interesting
> things about RMagick
>
> http://blog.pomozov.info/posts/adventure-with-rmagick-and-mongrel.html

Um... This is FC4 no sudo to worry about (there is a root account to
work from)

libs ARN'T in 'usr/local/lib' they are in 'usr/lib' (see top)

Running the irb or ruby tests above produce the same results under root.

Still stumped...

Lance

ara.t....@noaa.gov

unread,
Aug 2, 2006, 3:56:47 PM8/2/06
to
On Thu, 3 Aug 2006, Lance Squire wrote:

> Anatol Pomozov wrote:
>
>> Also you could read this article - you could find some interesting
>> things about RMagick
>>
>> http://blog.pomozov.info/posts/adventure-with-rmagick-and-mongrel.html
>
> Um... This is FC4 no sudo to worry about (there is a root account to
> work from)

you should never, never compile as root. fyi.

>
> libs ARN'T in 'usr/local/lib' they are in 'usr/lib' (see top)

and do you have ld.so configured to look there?


-a
--
we can never obtain peace in the outer world until we make peace with
ourselves.
- h.h. the 14th dali lama

Anatol Pomozov

unread,
Aug 2, 2006, 6:04:10 PM8/2/06
to


Add explicit
require 'rebygems'
to your code then


require 'rubygems'


require 'RMagick'
include Magick
cat = ImageList.new("Cheetah.jpg")
cat.display
exit

--
Posted via http://www.ruby-forum.com/.

Lance Squire

unread,
Aug 4, 2006, 10:05:16 AM8/4/06
to
Justin Collins wrote:
>
> If you are using a library installed with gems, you will need to
>
> require 'rubygems'
>
> first. Give that a try.
>
> -Justin

This dose make the test code from the 'Users guide' work.

Though you would think they would have included it....

Lance

Lance Squire

unread,
Aug 4, 2006, 10:06:20 AM8/4/06
to
Justin Collins wrote:
> require 'rubygems'
>
> first. Give that a try.
>
> -Justin

Unfortunatly, no love from rails...

Lance

Lance Squire

unread,
Aug 4, 2006, 10:11:31 AM8/4/06
to
unknown wrote:
>
> you should never, never compile as root. fyi.
>

Yes, but I must 'su' for the 'gem install rmagick' to work properly.

>>
>> libs ARN'T in 'usr/local/lib' they are in 'usr/lib' (see top)
>
> and do you have ld.so configured to look there?
>

Well, as Rails is working properly, and was installed the same way, I
presume that ld.so is pointing to 'usr/lib'

Can't find relevent ld.so to check...

# locate ld.so
/etc/ld.so.cache
/etc/ld.so.conf
/etc/ld.so.conf.d
/etc/ld.so.conf.d/mysql-i386.conf
/etc/ld.so.conf.d/qt-i386.conf
/usr/lib/librpmbuild.so
/usr/lib/kde3/kded_kssld.so
/usr/share/doc/man-pages-ja-20060115/translation_lists/ld.so.translation_list
/usr/share/man/ja/man8/ld.so.8.gz
/usr/share/man/man8/ld.so.8.gz

ara.t....@noaa.gov

unread,
Aug 4, 2006, 10:28:59 AM8/4/06
to
On Fri, 4 Aug 2006, Lance Squire wrote:

> unknown wrote:
>>
>> you should never, never compile as root. fyi.
>>
>
> Yes, but I must 'su' for the 'gem install rmagick' to work properly.

that means you are compiling as root. if the installs uses non-standard
library paths (LD_RUN_PATH or -r switch to ld.so) they will then fail at
runtime as doing this as root is silently ignored.

>>> libs ARN'T in 'usr/local/lib' they are in 'usr/lib' (see top)
>>
>> and do you have ld.so configured to look there?
>>
>
> Well, as Rails is working properly, and was installed the same way, I
> presume that ld.so is pointing to 'usr/lib'

rails doesn't require a properly configured ld.so since it uses now shared
libs

> Can't find relevent ld.so to check...
>
> # locate ld.so
> /etc/ld.so.cache
> /etc/ld.so.conf
> /etc/ld.so.conf.d
> /etc/ld.so.conf.d/mysql-i386.conf
> /etc/ld.so.conf.d/qt-i386.conf
> /usr/lib/librpmbuild.so
> /usr/lib/kde3/kded_kssld.so
> /usr/share/doc/man-pages-ja-20060115/translation_lists/ld.so.translation_list
> /usr/share/man/ja/man8/ld.so.8.gz
> /usr/share/man/man8/ld.so.8.gz

to check - find the '*.so' created by the 'gem instann rmagick' command, then
do something like

ldd RMagick.so

for instance

jib:~ > ldd /dmsp/reference/ruby-1.8.1/lib/ruby/site_ruby/1.8/i686-linux/RMagick.so
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x0086e000)
libz.so.1 => /usr/lib/libz.so.1 (0x002d6000)
libMagick.so.6 => /dmsp/reference/lib/libMagick.so.6 (0x00c1f000)
libtiff.so.3 => /dmsp/reference/lib/libtiff.so.3 (0x00e82000)
libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x0068f000)
libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x00ad4000)
libSM.so.6 => /usr/X11R6/lib/libSM.so.6 (0x00578000)
libICE.so.6 => /usr/X11R6/lib/libICE.so.6 (0x00111000)
libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x00128000)
libXt.so.6 => /usr/X11R6/lib/libXt.so.6 (0x009c1000)
libbz2.so.1 => /usr/lib/libbz2.so.1 (0x00e08000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00207000)
libm.so.6 => /lib/tls/libm.so.6 (0x0079a000)
libdl.so.2 => /lib/libdl.so.2 (0x003f7000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x0053a000)
libc.so.6 => /lib/tls/libc.so.6 (0x00ae2000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00506000)


-a
--
happiness is not something ready-made. it comes from your own actions.

Lance Squire

unread,
Aug 4, 2006, 10:41:58 AM8/4/06
to
Jeff Everett wrote:
> I usually use require_gem to get a gem into Rails:
>
> require 'rubygems'
> require_gem 'rmagick'
> include RMagick
>
> HTH,
> Jeff

This at least gives me a new error message.

----
uninitialized constant RMagick

Lance Squire

unread,
Aug 4, 2006, 10:56:13 AM8/4/06
to
unknown wrote:
>> Yes, but I must 'su' for the 'gem install rmagick' to work properly.
>
> that means you are compiling as root. if the installs uses non-standard
> library paths (LD_RUN_PATH or -r switch to ld.so) they will then fail at
> runtime as doing this as root is silently ignored.
>

should I then remove the package and again attempt to install as user?

(Thought I installed rails as user, but could not get rmagick to install
that way...)


> to check - find the '*.so' created by the 'gem instann rmagick' command,
> then

found:

]$ locate RMagick.so
/usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/ext/RMagick/RMagick.so
/usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/lib/RMagick.so

> do something like
>
> ldd RMagick.so
>

$ ldd /usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/lib/RMagick.so
linux-gate.so.1 => (0x00168000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x00385000)
libz.so.1 => /usr/lib/libz.so.1 (0x00fe5000)
libMagick.so.9 => /usr/lib/libMagick.so.9 (0x00ba8000)
liblcms.so.1 => /usr/lib/liblcms.so.1 (0x00e55000)
libtiff.so.3 => /usr/lib/libtiff.so.3 (0x00111000)
libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x00184000)
libgs.so.8 => /usr/lib/libgs.so.8 (0x00ff8000)
libXext.so.6 => /usr/lib/libXext.so.6 (0x001a6000)
libSM.so.6 => /usr/lib/libSM.so.6 (0x007b1000)
libICE.so.6 => /usr/lib/libICE.so.6 (0x006ce000)
libX11.so.6 => /usr/lib/libX11.so.6 (0x001b6000)
libXt.so.6 => /usr/lib/libXt.so.6 (0x00ef9000)
libbz2.so.1 => /usr/lib/libbz2.so.1 (0x002b3000)
libpthread.so.0 => /lib/libpthread.so.0 (0x002c3000)
libm.so.6 => /lib/libm.so.6 (0x002d7000)
libruby.so.1.8 => /usr/lib/libruby.so.1.8 (0x003f3000)
libdl.so.2 => /lib/libdl.so.2 (0x002fc000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x00889000)
libc.so.6 => /lib/libc.so.6 (0x004ed000)
libpng12.so.0 => /usr/lib/libpng12.so.0 (0x00300000)
libcupsimage.so.2 => /usr/lib/libcupsimage.so.2 (0x00328000)
libcups.so.2 => /usr/lib/libcups.so.2 (0x0075a000)
libssl.so.6 => /lib/libssl.so.6 (0x0033f000)
libcrypto.so.6 => /lib/libcrypto.so.6 (0x008b7000)
libnsl.so.1 => /lib/libnsl.so.1 (0x004d3000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x009ec000)
libXau.so.6 => /usr/lib/libXau.so.6 (0x004e9000)
libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00fb5000)
/lib/ld-linux.so.2 (0x00169000)
libgnutls.so.12 => /usr/lib/libgnutls.so.12 (0x00620000)
libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x0069b000)
libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x00ad9000)
libcom_err.so.2 => /lib/libcom_err.so.2 (0x006b4000)
libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x006e8000)
libresolv.so.2 => /lib/libresolv.so.2 (0x006b7000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x0070d000)
libgcrypt.so.11 => /usr/lib/libgcrypt.so.11 (0x0082c000)
libgpg-error.so.0 => /usr/lib/libgpg-error.so.0 (0x00e37000)
libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x006ca000)
and
]$ ldd /usr/lib/ruby/gems/1.8/gems/rmagick-1.13.0/ext/RMagick/RMagick.so
linux-gate.so.1 => (0x00168000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x006a1000)
libz.so.1 => /usr/lib/libz.so.1 (0x00d3f000)
libMagick.so.9 => /usr/lib/libMagick.so.9 (0x00184000)
liblcms.so.1 => /usr/lib/liblcms.so.1 (0x00487000)
libtiff.so.3 => /usr/lib/libtiff.so.3 (0x00cd9000)
libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x00125000)
libgs.so.8 => /usr/lib/libgs.so.8 (0x00f52000)
libXext.so.6 => /usr/lib/libXext.so.6 (0x00c0b000)
libSM.so.6 => /usr/lib/libSM.so.6 (0x004c5000)
libICE.so.6 => /usr/lib/libICE.so.6 (0x0079a000)
libX11.so.6 => /usr/lib/libX11.so.6 (0x004ce000)
libXt.so.6 => /usr/lib/libXt.so.6 (0x003b2000)
libbz2.so.1 => /usr/lib/libbz2.so.1 (0x00111000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00147000)
libm.so.6 => /lib/libm.so.6 (0x00449000)
libruby.so.1.8 => /usr/lib/libruby.so.1.8 (0x007b4000)
libdl.so.2 => /lib/libdl.so.2 (0x00e7e000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x00db5000)
libc.so.6 => /lib/libc.so.6 (0x00894000)
libpng12.so.0 => /usr/lib/libpng12.so.0 (0x0076d000)
libcupsimage.so.2 => /usr/lib/libcupsimage.so.2 (0x0040b000)
libcups.so.2 => /usr/lib/libcups.so.2 (0x005cb000)
libssl.so.6 => /lib/libssl.so.6 (0x00601000)
libcrypto.so.6 => /lib/libcrypto.so.6 (0x009c7000)
libnsl.so.1 => /lib/libnsl.so.1 (0x00422000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00afc000)
libXau.so.6 => /usr/lib/libXau.so.6 (0x00d75000)
libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x0015b000)
/lib/ld-linux.so.2 (0x00169000)
libgnutls.so.12 => /usr/lib/libgnutls.so.12 (0x00c1b000)
libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x0046e000)
libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x00de3000)
libcom_err.so.2 => /lib/libcom_err.so.2 (0x00121000)
libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x00646000)
libresolv.so.2 => /lib/libresolv.so.2 (0x0066b000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00438000)
libgcrypt.so.11 => /usr/lib/libgcrypt.so.11 (0x0070f000)
libgpg-error.so.0 => /usr/lib/libgpg-error.so.0 (0x00161000)
libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x00444000)

Sorry for longish posts...

ara.t....@noaa.gov

unread,
Aug 4, 2006, 11:15:29 AM8/4/06
to
On Fri, 4 Aug 2006, Lance Squire wrote:

> Sorry for longish posts...

no prob.

it looks RMagick compiled ok - otherwise you wouldn't have an so...


what do these commands do for you

harp:~ > ruby -r rubygems -e' require "RMagick"; p Magick '
Magick

if that doesn't work try

harp:~ > LD_LIBRARY_PATH=/usr/lib ruby -r rubygems -e' require "RMagick"; p Magick '
Magick

??

ara.t....@noaa.gov

unread,
Aug 4, 2006, 11:16:10 AM8/4/06
to
On Fri, 4 Aug 2006, Lance Squire wrote:

ah.

__that__ is your problem

it's Magick - not RMagick!

Lance Squire

unread,
Aug 4, 2006, 11:46:55 AM8/4/06
to
unknown wrote:

> what do these commands do for you
>
> harp:~ > ruby -r rubygems -e' require "RMagick"; p Magick '
> Magick
>

$ ruby -r rubygems -e' require "RMagick"; p Magick '
----
Magick
----

$ ruby -r rubygems -e' require "RMagick"; p Magick 'Magick
----
-e:1: warning: parenthesize argument(s) for future version
-e:1: undefined method `Magick' for #<Object:0xb7f3f970> (NoMethodError)
----


> if that doesn't work try
>
> harp:~ > LD_LIBRARY_PATH=/usr/lib ruby -r rubygems -e' require
> "RMagick"; p Magick '
> Magick
>

$ LD_LIBRARY_PATH=/usr/lib ruby -r rubygems -e' require
"RMagick"; p Magick '
-----
-e:1:in `require': wrong number of arguments (0 for 1) (ArgumentError)
from -e:1
-----

Lance Squire

unread,
Aug 4, 2006, 11:53:12 AM8/4/06
to
unknown wrote:
>
> __that__ is your problem
>
> it's Magick - not RMagick!
>
> -a

changing:


require 'rubygems'
require_gem 'rmagick'
include RMagick

to:
require 'rubygems'
require_gem 'rmagick'
include Magick

strangly produces this message:

undefined method `include' for #<MyBountyController:0xb796d1d4>

ara.t....@noaa.gov

unread,
Aug 4, 2006, 12:46:20 PM8/4/06
to
On Sat, 5 Aug 2006, Lance Squire wrote:

> unknown wrote:
>
>> what do these commands do for you
>>
>> harp:~ > ruby -r rubygems -e' require "RMagick"; p Magick '
>> Magick
>>
>
> $ ruby -r rubygems -e' require "RMagick"; p Magick '
> ----
> Magick
> ----

therefore, you've got it installed. if you are having issues with rails you
have issues with permissions or you have two rubys installed and the web users
is using a different one

> $ ruby -r rubygems -e' require "RMagick"; p Magick 'Magick
> ----
> -e:1: warning: parenthesize argument(s) for future version
> -e:1: undefined method `Magick' for #<Object:0xb7f3f970> (NoMethodError)
> ----

cut and past error. this is fine

>
>
>> if that doesn't work try
>>
>> harp:~ > LD_LIBRARY_PATH=/usr/lib ruby -r rubygems -e' require
>> "RMagick"; p Magick '
>> Magick


>>
>
> $ LD_LIBRARY_PATH=/usr/lib ruby -r rubygems -e' require
> "RMagick"; p Magick '
> -----
> -e:1:in `require': wrong number of arguments (0 for 1) (ArgumentError)
> from -e:1

that has to be on one line!


anyhow. you have installed RMagick and can use it fine from the command line.
what's your exact issue in rails then?

Lance Squire

unread,
Aug 4, 2006, 1:08:13 PM8/4/06
to
unknown wrote:
>> Magick
>> ----
>
> therefore, you've got it installed. if you are having issues with rails
> you
> have issues with permissions or you have two rubys installed and the web
> users
> is using a different one
>

This may or may not have happened when I tried to upgrade the version of
rails.
Don't know how to check and or rectify...

>
> anyhow. you have installed RMagick and can use it fine from the command
> line.
> what's your exact issue in rails then?
>

Trying to use Rmagick to make thumbnails of images previously stored on
the drive.

You've seen the errors above. here is the code as it stands now:

def make_thumb(location, image, thumb)


require 'rubygems'
require_gem 'rmagick'
include Magick

pic = Magick::Image.read("#{location}#{image}")
imgwidth = pic.columns
imgheight = pic.rows
imgratio = imgwidth.to_f / imgheight.to_f
imgratio > aspectratio ? scaleratio = 64 / imgwidth : scaleratio =
64 / imgheight
thumb = pic.resize(scaleratio)

white_bg = Magick::Image.new(64, thumb.height)
pic = white_bg.composite(thumb, Magick::CenterGravity,
Magick::OverCompositeOp)
pic.write("#{location}#{thumb}")
end

modified from this site:

http://www.bigbold.com/snippets/tag/rmagick
(bottom 2 examples)

ara.t....@noaa.gov

unread,
Aug 4, 2006, 1:20:35 PM8/4/06
to
On Sat, 5 Aug 2006, Lance Squire wrote:

> Trying to use Rmagick to make thumbnails of images previously stored on
> the drive.
>
> You've seen the errors above. here is the code as it stands now:

all your erros showed the constant 'RMagick' - that doesn't exist. it's
Magick, as you've got below. somewhere in your code you've got the constant
RMagick if you're actually getting the error shown.

>
> def make_thumb(location, image, thumb)
> require 'rubygems'
> require_gem 'rmagick'

this is 'RMagick' not 'rmagick'

> include Magick
>
> pic = Magick::Image.read("#{location}#{image}")
> imgwidth = pic.columns
> imgheight = pic.rows
> imgratio = imgwidth.to_f / imgheight.to_f
> imgratio > aspectratio ? scaleratio = 64 / imgwidth : scaleratio =
> 64 / imgheight
> thumb = pic.resize(scaleratio)
>
> white_bg = Magick::Image.new(64, thumb.height)
> pic = white_bg.composite(thumb, Magick::CenterGravity,
> Magick::OverCompositeOp)
> pic.write("#{location}#{thumb}")
> end

in short

- you've got RMagick installed correctly

- you've posted two errors caused by typos

1) RMagick vs Magick

2) require 'rmagick' vs. require 'RMagick'


the example i posted showed how to do both correctly.

for this you should be able to find your error. rest assured though, you have
correctly installed RMagick.

good luck.

Lance Squire

unread,
Aug 4, 2006, 1:44:19 PM8/4/06
to
unknown wrote:
> in short
>
> - you've got RMagick installed correctly
>
> - you've posted two errors caused by typos
>
> 1) RMagick vs Magick
>
> 2) require 'rmagick' vs. require 'RMagick'
>
>
> the example i posted showed how to do both correctly.
>

O.K.... :)

Still no Love...

This change:

def make_thumb(location, image, thumb)
require 'rubygems'

require_gem 'RMagick'
include Magick

pic = Magick::Image.read(location + image)

Produces this error:

Could not find RubyGem RMagick (> 0.0.0)

Lance Squire

unread,
Aug 4, 2006, 3:08:46 PM8/4/06
to
unknown wrote:
> rest assured though,
> you have
> correctly installed RMagick.
>
> good luck.
>
> -a

Thanks,

Guess I'll be moving this to a 'Rails can't see RMagick' thread...

ara.t....@noaa.gov

unread,
Aug 4, 2006, 3:18:23 PM8/4/06
to
On Sat, 5 Aug 2006, Lance Squire wrote:

> unknown wrote:
>> rest assured though,
>> you have
>> correctly installed RMagick.
>>
>> good luck.
>>
>> -a
>
> Thanks,
>
> Guess I'll be moving this to a 'Rails can't see RMagick' thread...

that's not the issue. rails is ruby. if ruby sees it rails sees it. what
might not see it is you web user's account, or some other variant.

try this from you rails root

./script/console

require 'RMagick'

p Magick


i'll bet it works

Lance Squire

unread,
Aug 4, 2006, 3:31:43 PM8/4/06
to
unknown wrote:
> try this from you rails root
>
> ./script/console
>
> require 'RMagick'
>
> p Magick
>
>
> i'll bet it works
>
> -a

Might help if I know what constitutes 'works' is ;)

Here's the output:

$ script/console
Loading development environment.
>> require 'RMagick'
=> true
>> p Magick
Magick
=> nil

ara.t....@noaa.gov

unread,
Aug 4, 2006, 4:34:18 PM8/4/06
to
On Sat, 5 Aug 2006, Lance Squire wrote:

> unknown wrote:
>> try this from you rails root
>>
>> ./script/console
>>
>> require 'RMagick'
>>
>> p Magick
>>
>>
>> i'll bet it works
>>
>> -a
>
> Might help if I know what constitutes 'works' is ;)
>
> Here's the output:
>
> $ script/console
> Loading development environment.
>>> require 'RMagick'
> => true
>>> p Magick
> Magick
> => nil
>>>

so, there you have it - ruby, rmagick, and rails altogether. any errors you
have now are, unfortunately, purely bugs in your own code ;-(


in this one

http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/8b1dd2eef7f7c0ef/63605438ec4258a2?hl=en#63605438ec4258a2

it's

require 'rubygems'
require 'RMagick'

not just

require 'RMagick'


in this one

http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/8b1dd2eef7f7c0ef/63605438ec4258a2?hl=en#63605438ec4258a2

it's

Magick

not

RMagick


in this one

http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/8b1dd2eef7f7c0ef/63605438ec4258a2?hl=en#63605438ec4258a2


you are running the requires and includes at instance, not class level


etc.


you've got everything installed correctly and rails sees it too. now you've
just got to work out the bugs.

regards.

Lance Squire

unread,
Aug 8, 2006, 9:53:46 AM8/8/06
to
unknown wrote:
>
> you've got everything installed correctly and rails sees it too. now
> you've
> just got to work out the bugs.
>
> regards.
>
>
> -a

Thanks for the debugging/verifying so far.
(Just got back to the project)

I have tried moveing the:

require 'rubygems'
require_gem 'RMagick'

above and just below the "class" line in the controller. In either case
I get:
-----
Gem::LoadError in <controller not set>#<action not set>

Could not find RubyGem RMagick (> 0.0.0)

-----

Contrary to the previous tests this is telling me that it cant find
RMagick...

lance

Lance Squire

unread,
Aug 8, 2006, 1:28:44 PM8/8/06
to
unknown wrote:
> you are running the requires and includes at instance, not class level
>
>
> etc.

After Much more Googleing for working code samples.

I notice that they All had the "require 'RMagick'" under the 'def' line.

This put me back to the error:

----
undefined method `columns' for #<Array:0xb791c810>
----

I have long forgotten why I removed the '.first' from the:

pic = Magick::Image.read(location + image).first

line, so I replaced it.

NOW things started giving me errors I could understand!!!

As the latest sample was far more eloquent than the original I was
trying to use, I substuted it for some of the code that wasn't working,
beacuse I missed something from the original code.

This is the result:

def make_thumb(location, image, thumb)
#require 'rubygems'
#require_gem 'RMagick'
#include Magick
require 'RMagick'

pic = Magick::Image.read(location + image).first
#imgwidth = pic.columns
#imgheight = pic.rows
#imgratio = imgwidth.to_f / imgheight.to_f
#imgratio > aspectratio ? scaleratio = 64 / imgwidth : scaleratio =
64 / imgheight
#thumb = pic.resize(scaleratio)
pic.change_geometry!('64x64') { |cols, rows, img|
pic.resize!(cols, rows)}

white_bg = Magick::Image.new(64, 64)
pic = white_bg.composite(pic, Magick::CenterGravity,
Magick::OverCompositeOp)
pic.write(location + thumb)
end

or more cleaned-up as:

def make_thumb(location, image, thumb)
require 'RMagick'

pic = Magick::Image.read(location + image).first
pic.change_geometry!('64x64') { |cols, rows, img|
pic.resize!(cols, rows)}

white_bg = Magick::Image.new(64, 64)
pic = white_bg.composite(pic, Magick::CenterGravity,
Magick::OverCompositeOp)
pic.write(location + thumb)
end

This code works flawlessly!

Unfortunatly, My original attempts to fix the original error were,
misguided and caused more errors than could probably be debugged
remotly.

Much thanks for conferming that RMagick was installed and working
properly.

Lance F. Squire

0 new messages