Can't use Gruff with Rails

Hello list,

I’m having a problem getting Gruff working with Rails on a Windows XP
box.

I installed RMagick, then Gruff via the win32 gem, and it seemed to go
OK. From irb, I can do the following

  • require ‘rubygems’ ##### This returns ‘false’, but seems to work OK
  • require ‘gruff’ ####### Ditto
  • g = Gruff::Bar.new
    etc., and I get a nice PNG file containing my graph

Despite the fact that the two ‘require’ statements are returning
false, Gruff still appears accessible.

Within Rails, it doesn’t seem to work at all. I’ve tried
require ‘gruff’

and

require ‘rubygems’
require ‘gruff’

at the top of a controller, but Rails falls over with
no such file to load – gruff
whenever I access that controller. It looks like Gruff isn’t there,
except that it actually works OK from irb (in spite of not appearing
to be there!!!).

Does anyone have any clue what’s going on here?

Thanks in advance

Dave M.

Nice pickup about needing to

  • require_gem ‘gruff’
    but it didn’t quite fix things. Now I’m getting
  • Could not find RubyGem gruff (> 0.0.0)
    from within Rails.

However, irb gives a ‘true’ when I require_gem ‘gruff’ so it’s
definitely improved things slightly.

I stop/started Webrick but it didn’t change things.

Thanks anyway. Got any other thoughts?

Regards

Dave M.

On Thu, 2006-02-23 at 12:38 +1100, David M. wrote:

Hello list,

I’m having a problem getting Gruff working with Rails on a Windows XP box.

I installed RMagick, then Gruff via the win32 gem, and it seemed to go
OK. From irb, I can do the following

  • require ‘rubygems’ ##### This returns ‘false’, but seems to work OK
  • require ‘gruff’ ####### Ditto

Might want to do a require_gem ‘gruff’ instead here.

Within Rails, it doesn’t seem to work at all. I’ve tried
require ‘gruff’

This happened to me until I restarted Apache… after that all was well.
Worth a shot, anyhow…

Yours,

Tom

David, What happens in irb when you type require ‘RMagick’ ?

On Thu, 2006-02-23 at 13:47 +1100, David M. wrote:

Thanks anyway. Got any other thoughts?

Hm, is there anything helpful in the logs? When I had this problem (on
Fedora Core 4) one of the problems was that ImageMagick couldn’t find
the font it wanted - in my case, it was Arial.ttf.

As “De Railed” suggested, what happens when you type “require ‘rmagick’”
in irb?

Yours,

tom

require ‘RMagick’ gives a false as well

Not sure what you mean about checking the logs. irb doesn’t write
verbose logging messages anywhere, does it?

Thanks

Dave M.

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
David M.
Sent: Thursday, February 23, 2006 2:56 PM
To: [email protected]
Subject: Re: [Rails] Can’t use Gruff with Rails

require ‘RMagick’ gives a false as well

Hm, what about “require_gem ‘rmagick’” ?

Not sure what you mean about checking the logs. irb doesn’t
write verbose logging messages anywhere, does it?

Nah, I was thinking the Apache or Webrick logs… maybe there’s some
sort of error appearing in there…

Yours,

Tom

Gem::LoadError: Could not find RubyGem rmagick (> 0.0.0)
Hm, interesting! Seems like that may be the problem… if you do a
“gem list” from the command line, is rmagick in that list? Probably
not… do you get error messages when you do a “gem install rmagick”?

Yours,

Tom

irb(main):001:0>require_gem ‘rmagick’
Gem::LoadError: Could not find RubyGem rmagick (> 0.0.0)

    from c:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:204:in 

report_activate_ error' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:141:inactivate’
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:37:in
require_gem_with_ options' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:31:inrequire_gem’
from (irb):1
irb(main):002:0>

Absolutely nothing in the Webrick log…

As I said earlier, even though require_gem ‘gruff’ fails, from within
irb I can still create new Gruff objects successfully.

Very frustrating…

Thanks

Dave M.

On Fri, 2006-02-24 at 08:35 +1100, David M. wrote:

That’s why I resorted to downloading RMagick by hand
(RMagick-1.9.2-IM-6.2.4-6-win32.zip).

Ah, that’s right, Tim distributes a prebuilt win32 binary, I’d forgotten
about that.

It seems to have (sort of) worked, because I can
create a .png graph from Gruff under irb; it’s just the require…
returning a false that seems to be catching me out.

Hm. I’m flummoxed… if anything else occurs to me, I’ll let you
know…

Yours,

tom

OK

Thanks Tom for your help to date. I’ll update this thread if a solution
appears

Searching via Google, it seems that a few people have had similar
problems with Gruff on Win XP, but no-one’s ever posted a fix.

Regards

Dave M.

‘gem list’ includes
RMagick-win32 (1.9.2)
RMagick is an interface between the Ruby programming language and
the ImageMagick and GraphicsMagick image processing libraries.
so it looks like it’s there OK.

I just did another ‘gem install rmagick’ to see if it made any
difference. I forgot this happened before, but this is what I got:
Attempting local installation of ‘rmagick’
Local gem file not found: rmagick*.gem
Attempting remote installation of ‘rmagick’
Updating Gem source index for: http://gems.rubyforge.org
Building native extensions. This could take a while…
configure:1: Can’t exec \bin\sh (fatal)
ERROR: While executing gem … (RuntimeError)
ERROR: Failed to build gem native extension.
Gem files will remain installed in
c:/ruby/lib/ruby/gems/1.8/gems/rmagick-1.10.0
for inspection.
ruby configure install rmagick\n

Results logged to
c:/ruby/lib/ruby/gems/1.8/gems/rmagick-1.10.0/gem_make.out

That’s why I resorted to downloading RMagick by hand
(RMagick-1.9.2-IM-6.2.4-6-win32.zip). This file contained a
RMagick-win32-1.9.2-mswin32.gem, which installed without problems. I
then ran ‘postinstall.rb’ as per the README file, and it also ran
without problems. It seems to have (sort of) worked, because I can
create a .png graph from Gruff under irb; it’s just the require…
returning a false that seems to be catching me out.

Thanks again

Dave M.