Getting Warning from require savon in ruby

57 Views Asked by At

Ubuntu 18.04, ruby 2.5.1p57

I have a ruby program that I use on a number of different linux system. On one it produces a screed of warning from require 'savon'

elasticsearch@secesprd02:~$ ruby /usr/local/tools/dev/es-cluster/bin/send-json.rb  -v --cluster test -c /usr/local/tools/dev/conf/conf.json  -r name=ES-api-winlogbeat json/winlogbeat-api-key
/var/lib/gems/2.5.0/gems/akami-1.3.1/lib/akami/wsse.rb:99: warning: shadowing outer local variable - key
/var/lib/gems/2.5.0/gems/akami-1.3.1/lib/akami/wsse.rb:99: warning: shadowing outer local variable - v1
/var/lib/gems/2.5.0/gems/akami-1.3.1/lib/akami/wsse.rb:99: warning: shadowing outer local variable - v2
/usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59: warning: loading in progress, circular require considered harmful - /var/lib/gems/2.5.0/gems/gyoku-1.3.1/lib/gyoku/hash.rb
    from /usr/local/tools/dev/es-cluster/bin/send-json.rb:8:in  `<main>'
    from /usr/local/tools/dev/es-cluster/bin/send-json.rb:8:in  `require_relative'
    from /usr/local/tools/dev/common-library/lib/app-configure.rb:3:in  `<top (required)>'
    from /usr/local/tools/dev/common-library/lib/app-configure.rb:3:in  `require_relative'
    from /usr/local/tools/common-library/lib/SecretServer.rb:1:in  `<top (required)>'
    from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in  `require'
    from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in  `rescue in require'
    from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in  `require'
    from /var/lib/gems/2.5.0/gems/savon-2.12.1/lib/savon.rb:26:in  `<top (required)>'
    from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in  `require'
...

The program runs without any obvious problems apart from the warings.

I have updated savon and akami gems but this made no difference.

1

There are 1 best solutions below

0
Marcos Parreiras On

The warning is caused due to

loading in progress, circular require considered harmful - /var/lib/gems/2.5.0/gems/gyoku-1.3.1/lib/gyoku/hash.rb

That should not cause you any harm, given that the require keeps track of files already loaded, so the behaviour of your application should not be affected in any way.

A good overview on that can be found on this answer.

Under normal circumstances it's fine to require the same file twice, because require keeps a record of the libraries it has loaded and ignores a second call.

It looks as if you get this error if the library you are requiring requires itself somehow, which is not something that require can cope with -- the require operation presumably needs to complete before the library is added to the list.

So if in a.rb you require b.rb and in b.rb you require a.rb. then when you write require "a" Ruby will
* start to require a.rb
* start to require b.rb
* start to require a.rb again and realise there is something terribly wrong.