Saturday, May 15, 2010

NameError: uninitialized constant GData

I was trying out the GData gem from Google as part of my chex rewrite when I got struck with a bit of an idea how the Ruby console works. This has been one of the things I've loved about programming in Ruby as opposed to Java / NET or the other programming languages I program in. I installed the gem using: "sudo gem install gdata" which worked like a treat. Next thing I did was fire up the console to start playing around with gem - "ruby script/console", only to be greeted by this error.

  1. trevors-macbook-4:chexscheduler trevor$ ruby script/console
  2. Loading development environment (Rails 2.3.5)
  3. /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. Use #requirement
  4. >> client =
  5. NameError: uninitialized constant GData
  6. from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:443:in `load_missing_constant'
  7. from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing'
  8. from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in `const_missing'
  9. from (irb):1
  10. >> client =
  11. NameError: uninitialized constant GData
  12. from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:443:in `load_missing_constant'
  13. from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing'
  14. from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in `const_missing'
  15. from (irb):2
  16. >> client =
  17. NameError: uninitialized constant GData
  18. from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:443:in `load_missing_constant'
  19. from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing'
  20. from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in `const_missing'
  21. from (irb):3
  22. >> ^Dtrevors-macbook-4:chexscheduler trevor$
  23. trevors-macbook-4:chexscheduler trevor$ clear
This is peculiar as the gem has already been installed globally. However, as it was not added to the environment.rb, it was not picked up during the launch of the console. Only when I added the line " config.gem 'gdata', :lib => 'gdata' " to environment.rb and relaunched the console did it work. Back to playing around with the gem.

No comments: