Beginner issue: ./savon.rb:41: uninitialized constant Savon (NameError)

330 views
Skip to first unread message

TJ Yang

unread,
Aug 1, 2011, 9:58:19 PM8/1/11
to sav...@googlegroups.com
I am migrating a perl soap client script over to Ruby using savon.
Need help to get pass this roadblock,  "uninitialized constant Savon (NameError)"

Any idea where I did wrong ?

1. OS and test script s1.rb
[root@t-fedora14-32 ruby]# cat /etc/redhat-release
Fedora release 14 (Laughlin)
[root@t-fedora14-32 ruby]# cat s1.rb
#!/bin/env ruby
#
require 'rubygems'
require 'savon'
client = Savon::Client.new do
  wsdl.document = "http://service.example.com?wsdl"
end
[root@t-fedora14-32 ruby]#

2. The error message


[root@t-fedora14-32 ruby]# ./s1.rb
./savon.rb:41: uninitialized constant Savon (NameError)
        from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
        from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
        from ./s1.rb:4
[root@t-fedora14-32 ruby]#

3. ruby and gem info
[root@t-fedora14-32 ruby]# gem -v
1.8.1
[root@t-fedora14-32 ruby]# gem list |grep savon
savon (0.9.6, 0.9.2)
[root@t-fedora14-32 ruby]#


Alex Katebi

unread,
Aug 1, 2011, 11:18:58 PM8/1/11
to sav...@googlegroups.com
You need to install the savon gem
By the way savon is flaky in ruby 1.9.2. use 1.8.7 instead

gem install savon

TJ Yang

unread,
Aug 2, 2011, 8:27:06 AM8/2/11
to sav...@googlegroups.com
Here is another try, I removed existing savon 0.9.2 and 0.9.6 and install 0.9.6 again.
See the irb debug log, the error message is from savron.rb line 41.

[root@fl36t-fedora14-32 ruby]# gem -v
1.8.6
[root@t-fedora14-32 ruby]# ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-linux]
[root@fl36t-fedora14-32 ruby]# gem list |grep savon
savon (0.9.6, 0.9.2)
[root@t-fedora14-32 ruby]# gem uninstall  savon

Select gem to uninstall:
 1. savon-0.9.2
 2. savon-0.9.6
 3. All versions
> 3
Successfully uninstalled savon-0.9.2
Successfully uninstalled savon-0.9.6
[root@fl36t-fedora14-32 ruby]# 
[root@t-fedora14-32 ruby]# gem install  --http-proxy http:/test.com.com:8080 savon
Fetching: savon-0.9.6.gem (100%)
Successfully installed savon-0.9.6
1 gem installed
Installing ri documentation for savon-0.9.6...
Installing RDoc documentation for savon-0.9.6...
[root@t-fedora14-32 ruby]# irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'savon'
NameError: uninitialized constant Savon
        from ./savon.rb:41
        from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
        from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
        from (irb):2
        from :0
irb(main):003:0>

Alex Katebi

unread,
Aug 2, 2011, 8:33:18 AM8/2/11
to sav...@googlegroups.com
In ruby 1.8.7 you need to do "require 'rubygems'" before any other require.

Alex Katebi

unread,
Aug 2, 2011, 8:36:54 AM8/2/11
to sav...@googlegroups.com
Are you using rvm? I am trying to see if I get your error.

On Tue, Aug 2, 2011 at 8:27 AM, TJ Yang <tjyan...@gmail.com> wrote:

Alex Katebi

unread,
Aug 2, 2011, 8:40:17 AM8/2/11
to sav...@googlegroups.com
It looks like that your savon gem installed with errors but you thought it went ok. I suggest you do:

gem install savon --no-rdoc --no-ri

I just did it with no errors.

On Tue, Aug 2, 2011 at 8:27 AM, TJ Yang <tjyan...@gmail.com> wrote:

TJ Yang

unread,
Aug 2, 2011, 9:13:55 AM8/2/11
to sav...@googlegroups.com

Argh, My bad, I havea  test savon script named as "savon.rb", so "require" command import "./savon.rb" first and generate the error message.

Alex, thanks for your help.

tj
Reply all
Reply to author
Forward
0 new messages