Ruby Forum Ruby > CAPTCHA gem

Posted by Ss Kk (kisrti)
on 15.05.2008 10:55
Hi All,

I am using 'captcha gem' in my code to implement 'CAPTCHA' functionality
,It gives following error :
---------------------------------------------------------------------------------------------------------
 MissingSourceFile in UserController#sign_in

no such file to load -- GD

RAILS_ROOT: ./script/../config/..
Application Trace | Framework Trace | Full Trace

d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in
`new_constants_in'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/captcha-0.1.2/lib/captcha.rb:22
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in
`gem_original_require'
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in
`new_constants_in'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
`require'
#{RAILS_ROOT}/app/controllers/user_controller.rb:9

d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in
`new_constants_in'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/captcha-0.1.2/lib/captcha.rb:22
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in
`gem_original_require'
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in
`new_constants_in'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:203:in
`load_without_new_constant_marking'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:203:in
`load_file'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in
`new_constants_in'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:202:in
`load_file'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:94:in
`require_or_load'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:248:in
`load_missing_constant'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:452:in
`const_missing'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:464:in
`const_missing'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/inflector.rb:250:in
`constantize'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/core_ext/string/inflections.rb:148:in
`constantize'
d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/routing.rb:1284:in
`recognize'
d:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:40:in
`dispatch'
d:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:113:in
`handle_dispatch'
d:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:79:in
`service'
d:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
d:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
d:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
d:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
d:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
d:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
d:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
d:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
d:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
d:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
d:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:63:in
`dispatch'
d:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/servers/webrick.rb:59
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in
`new_constants_in'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:39
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
script/server:3

d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in
`new_constants_in'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/captcha-0.1.2/lib/captcha.rb:22
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in
`gem_original_require'
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in
`new_constants_in'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
`require'
#{RAILS_ROOT}/app/controllers/user_controller.rb:9
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:203:in
`load_without_new_constant_marking'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:203:in
`load_file'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in
`new_constants_in'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:202:in
`load_file'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:94:in
`require_or_load'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:248:in
`load_missing_constant'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:452:in
`const_missing'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:464:in
`const_missing'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/inflector.rb:250:in
`constantize'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/core_ext/string/inflections.rb:148:in
`constantize'
d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/routing.rb:1284:in
`recognize'
d:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:40:in
`dispatch'
d:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:113:in
`handle_dispatch'
d:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:79:in
`service'
d:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
d:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
d:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
d:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
d:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
d:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
d:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
d:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
d:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
d:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
d:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:63:in
`dispatch'
d:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/servers/webrick.rb:59
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in
`new_constants_in'
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
`require'
d:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:39
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
script/server:3

This error occurred while loading the following files:
   captcha
   GD

Request

Parameters: None

Show session dump

---
:user_id:
:fr: {}

flash: !map:ActionController::Flash::FlashHash {}


Response
Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"}
---------------------------------------------------------------------------------------------------------
I have installed  gem gd1.1 ,Still it's not working.

Tell me if anyone can help me to come out of this problem?
Posted by Axel Etzold (Guest)
on 15.05.2008 11:56
(Received via mailing list)
-------- Original-Nachricht --------
> Datum: Thu, 15 May 2008 17:55:06 +0900
> Von: Ss Kk <1shweta2@gmail.com>
> An: ruby-talk@ruby-lang.org
> Betreff: CAPTCHA gem

> Application Trace | Framework Trace | Full Trace
> 
> d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
> `gem_original_require'
> d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
> `require'
> 

Hello,

do you require rubygems in your script, ie., do you have a line

require "rubygems"

before

require "captcha" ...

in your script ?
Maybe you can post some shortened bit of code ...

Best regards,

Axel
Posted by Ss Kk (kisrti)
on 15.05.2008 12:16
Axel Etzold wrote:
> -------- Original-Nachricht --------
>> Datum: Thu, 15 May 2008 17:55:06 +0900
>> Von: Ss Kk <1shweta2@gmail.com>
>> An: ruby-talk@ruby-lang.org
>> Betreff: CAPTCHA gem
> 
>> Application Trace | Framework Trace | Full Trace
>> 
>> d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
>> `gem_original_require'
>> d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
>> `require'
>> 
> 
> Hello,
> 
> do you require rubygems in your script, ie., do you have a line
> 
> require "rubygems"
> 
> before
> 
> require "captcha" ...
> 
> in your script ?
> Maybe you can post some shortened bit of code ...
> 
> Best regards,
> 
> Axel

Hi,
    Thanks for your reply Butit is not making any change ,Still same 
error


Here is code of my user controller:
require 'rubygems'
require 'captcha'//Gives error to this line

class UserController < ApplicationController

  def register
     var= CAPTCHA::Web.new
     var.to_html("captcha_temp")
  end
end

And code of Captcha file: ,you will get :

"D:\ruby\lib\ruby\gems\1.8\gems\captcha-0.1.2\lib\captcha.rb"
(If installed Captha gem)


Tell me what's going wrong.
Posted by Vassilis Rizopoulos (Guest)
on 15.05.2008 12:43
(Received via mailing list)
Ss Kk wrote:
>  Hi All,
>
>  I am using 'captcha gem' in my code to implement 'CAPTCHA'
>  functionality ,It gives following error :
> 
---------------------------------------------------------------------------------------------------------
>  MissingSourceFile in UserController#sign_in
>
>  no such file to load -- GD
>
>  RAILS_ROOT: ./script/../config/.. Application Trace | Framework Trace
>  | Full Trace
>
>  d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
>  `gem_original_require'
Well, from what you posted, require 'rubygems' is done somewhere in the
code you load (that's the custom_require line right there) and I guess
the captcha gem tries to load GD and cannot find it.
So your problem is either that GD is not correctly installed or that you
don't have the correct GD version.
Try to isolate the problem by making a small unit test of just a test
program that does only the one thing you're trying to do here:

require 'rubygems'
require 'captcha'

var= CAPTCHA::Web.new
p var.to_html("captcha_temp")

so that you don't have all the Rails snick-snack to wade through.

Also, here's a link to a discussion talking about the captcha  gem
http://groups.google.com/group/uso-dev/browse_thread/thread/63642201fb194e0d

I think it mentions that it needs the ruby-gd gem and that that gem is
source-only (so you need to compile yourself)

V.-
Posted by Axel Etzold (Guest)
on 15.05.2008 12:52
(Received via mailing list)
-------- Original-Nachricht --------
> Datum: Thu, 15 May 2008 19:16:41 +0900
> Von: Ss Kk <1shweta2@gmail.com>
> An: ruby-talk@ruby-lang.org
> Betreff: Re: CAPTCHA gem

> >> `gem_original_require'
> > before
> Hi,
>   def register
> 
> Tell me what's going wrong.
> -- 
> Posted via http://www.ruby-forum.com/.

Hello,

there is a dependency problem. The captcha gem wants to load
the GD library

http://www.boutell.com/gd/

(which is not written in Ruby).
You'll have to install that and probably one of the Ruby bindings
to GD.
From a search on Rubyforge, I gather that the Ruby gem GD is now
called ruby-gd.
As the captcha gem you're trying to install has its last release
on March 28, 2004 and the now-name-changed GD/ruby-gd gem releases only
one file, from  January, 30th, 2007, there might have happened some 
changes
in the meantime, I'm afraid :-(

Maybe it's good idea to contact the author of the ruby-gd gem
to ask for help ... or use some other turing test gem, like turing.

Best regards,

Axel
Posted by Ss Kk (kisrti)
on 16.05.2008 07:02
Hi ,
     thanks for this.Now its working for me.