Issue #13040 has been updated by Luis Mondesi.


Nobuyoshi Nakada wrote:
> 'syslog/logger.rb' and 'logger.rb' are different files.
> What do you mean by "test"?

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. 

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. 

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. 


----------------------------------------
Bug #13040: syslog/logger uses "require 'logger'" which is interpreted as circular dependency 
https://bugs.ruby-lang.org/issues/13040#change-62103

* Author: Luis Mondesi
* Status: Feedback
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
while using the 'syslog/logger' require from Ruby it works well, however if one tries to use it via "test" it complaints about circular require and the constant "Logger" not defined. After a little digging, I realized that 'syslog/logger' has a line that says require 'logger' which could mean itself!

The fix is to use require_relative '../logger' as this is what it intends in order to piggy back on Logger:

Current code for syslog/logger:

1. # frozen_string_literal: false
2. require 'syslog'
3. require 'logger'

Fixed code:

1. # frozen_string_literal: false
2. require 'syslog'
3. require_relative '../logger'



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>