在 ruby​​ 中从 require savon 获取警告

发布于 2025-01-20 21:42:09 字数 1767 浏览 1 评论 0原文

Ubuntu 18.04,Ruby 2.5.1p57

我有一个在许多不同Linux系统上使用的Ruby程序。在其中,它会从中产生一个警告的丝网,需要“ 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'
...

该程序运行,除了警告外,没有明显的问题。

我已经更新了Savon和Akami Gems,但这没什么区别。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

葬﹪忆之殇 2025-01-27 21:42:09

警告是由于

正在加载中,循环需要被视为有害 -/var/lib/gems/2.5.0/gems/gyoku-1.3.1/lib/gyoku/hash.rb

,鉴于需要跟踪已经加载的文件,因此您的应用程序的行为不应以任何方式受到影响。

可以在上,可以找到一个很好的概述。

在正常情况下,需要两次相同的文件,因为需要保留已加载的库的记录并忽略第二个呼叫。

如果您需要的库,好像您会收到此错误
需要以某种方式需要自己,这不是需要应对的
与 - 要求操作大概需要完成
库已添加到列表中。

因此,如果在A.RB中您需要B.RB,则在B.RB中,您需要A.RB。然后,当您编写时需要“ A” Ruby将会

*开始需要A.RB

*开始需要B.RB

*开始再次需要A.RB,并意识到有些问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文