https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112016-12-16T01:15:12ZRuby Issue Tracking SystemRuby master - Bug #13040: syslog/logger uses "require 'logger'" which is interpreted as circular dependency https://bugs.ruby-lang.org/issues/13040?journal_id=620512016-12-16T01:15:12Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>'syslog/logger.rb' and 'logger.rb' are different files.<br>
What do you mean by "test"?</p> Ruby master - Bug #13040: syslog/logger uses "require 'logger'" which is interpreted as circular dependency https://bugs.ruby-lang.org/issues/13040?journal_id=620522016-12-16T01:15:24Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul> Ruby master - Bug #13040: syslog/logger uses "require 'logger'" which is interpreted as circular dependency https://bugs.ruby-lang.org/issues/13040?journal_id=621032016-12-20T02:33:48Zlemsx1 (Luis Mondesi)lemsx1@gmail.com
<ul></ul><p>Nobuyoshi Nakada wrote:</p>
<blockquote>
<p>'syslog/logger.rb' and 'logger.rb' are different files.<br>
What do you mean by "test"?</p>
</blockquote>
<p>For example, I setup a new Rails 5.0.0.1 app and minitest for use with "spec" via a test_helper file, nothing out of the norm. Then ran "rake test" and saw a complaint (warning) about "circular dependency". If I turn the warnings off, then you won't see the message, but would fail saying logger constant is not defined. It took me a little while to realize that both syslog/logger and "logger" are both in the path while "require 'logger'" is called from syslog/logger.</p>
<p>And like I said above, require_relative disambiguate the call and makes it very clear that you mean to require the "logger" from the previous directory.</p>
<p>While my app runs I do not get this warning or error, it only happens in "test mode". Whatever minitest does to run tests causes Ruby to get confused.</p> Ruby master - Bug #13040: syslog/logger uses "require 'logger'" which is interpreted as circular dependency https://bugs.ruby-lang.org/issues/13040?journal_id=648782017-05-18T13:55:53Zlemsx1 (Luis Mondesi)lemsx1@gmail.com
<ul></ul><p>Am I the only person having this problem? This is in different code sources we are maintaining. Here is the latest. In a new project I setup test with minitest/spec</p>
<ol>
<li>added pp $LOAD_PATH to my test_helper.rb</li>
<li>rake test</li>
</ol>
<p>$> rake test<br>
["/Users/lmondesi/Projects/new_project/lib",<br>
"/Users/lmondesi/Projects/new_project/lib/new_project",<br>
"/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib",<br>
"/usr/local/lib/ruby/gems/2.4.0/gems/did_you_mean-1.1.0/lib",<br>
"/usr/local/lib/ruby/gems/2.4.0/gems/minitest-5.10.1/lib",<br>
"/usr/local/lib/ruby/site_ruby/2.4.0",<br>
"/usr/local/lib/ruby/site_ruby/2.4.0/x86_64-darwin16",<br>
"/usr/local/lib/ruby/site_ruby",<br>
"/usr/local/lib/ruby/vendor_ruby/2.4.0",<br>
"/usr/local/lib/ruby/vendor_ruby/2.4.0/x86_64-darwin16",<br>
"/usr/local/lib/ruby/vendor_ruby",<br>
"/usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0",<br>
"/usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/x86_64-darwin16"]<br>
/usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/syslog/logger.rb:81:in <code><class:Logger>': uninitialized constant Logger (NameError) from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/syslog/logger.rb:48:in </code><top (required)>'<br>
from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in <code>require' from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in </code>require'</p> Ruby master - Bug #13040: syslog/logger uses "require 'logger'" which is interpreted as circular dependency https://bugs.ruby-lang.org/issues/13040?journal_id=653202017-06-08T15:46:33Zlemsx1 (Luis Mondesi)lemsx1@gmail.com
<ul></ul><p>Ok, I was able to reproduce this now.</p>
<ol>
<li>create a new Rails Project</li>
<li>create an initializer under configs/initializer named "delayed_job.rb" with:</li>
</ol>
<p>require 'syslog/logger'</p>
<p>Delayed::Worker.delay_jobs = !Rails.env.test?<br>
Delayed::Worker.logger = Rails.logger</p>
<a name="hack-to-reopen-syslog-in-local1"></a>
<h1 >hack to reopen syslog in local1<a href="#hack-to-reopen-syslog-in-local1" class="wiki-anchor">¶</a></h1>
<p>Syslog::Logger.syslog.close<br>
Syslog::Logger.syslog = Syslog.open('bmanage', Syslog::LOG_ODELAY, Syslog::LOG_LOCAL1)</p>
<ol start="3">
<li>run bin/rake test or bundle exec rake test</li>
</ol>
<p>Essentially, this was required with older libraries of Syslog::Logger. Now that Syslog::Logger allows one to change facility when initializing an instance, there is no need for this code.</p>
<p>After removing this code, the bug went away!</p>
<p>You can now close this issue.</p> Ruby master - Bug #13040: syslog/logger uses "require 'logger'" which is interpreted as circular dependency https://bugs.ruby-lang.org/issues/13040?journal_id=653222017-06-09T03:21:54Zhsbt (Hiroshi SHIBATA)hsbt@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Rejected</i></li></ul>