ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: lemsx1@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:81224] [Ruby trunk Bug#13040] syslog/logger uses "require 'logger'" which is interpreted as circular dependency
Date: Thu, 18 May 2017 13:55:53 +0000	[thread overview]
Message-ID: <redmine.journal-64878.20170518135553.160025987cea0412@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-13040.20161215191125@ruby-lang.org

Issue #13040 has been updated by lemsx1 (Luis Mondesi).


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

1. added pp $LOAD_PATH to my test_helper.rb
2. rake test

$> rake test
["/Users/lmondesi/Projects/new_project/lib",
 "/Users/lmondesi/Projects/new_project/lib/new_project",
 "/usr/local/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib",
 "/usr/local/lib/ruby/gems/2.4.0/gems/did_you_mean-1.1.0/lib",
 "/usr/local/lib/ruby/gems/2.4.0/gems/minitest-5.10.1/lib",
 "/usr/local/lib/ruby/site_ruby/2.4.0",
 "/usr/local/lib/ruby/site_ruby/2.4.0/x86_64-darwin16",
 "/usr/local/lib/ruby/site_ruby",
 "/usr/local/lib/ruby/vendor_ruby/2.4.0",
 "/usr/local/lib/ruby/vendor_ruby/2.4.0/x86_64-darwin16",
 "/usr/local/lib/ruby/vendor_ruby",
 "/usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0",
 "/usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/x86_64-darwin16"]
/usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/syslog/logger.rb:81:in `<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 `<top (required)>'
	from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'

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

* Author: lemsx1 (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/

  parent reply	other threads:[~2017-05-18 13:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-13040.20161215191125@ruby-lang.org>
2016-12-15 19:11 ` [ruby-core:78668] [Ruby trunk Bug#13040] syslog/logger uses "require 'logger'" which is interpreted as circular dependency lemsx1
2016-12-16  1:15 ` [ruby-core:78673] " nobu
2016-12-16  1:15 ` [ruby-core:78674] [Ruby trunk Bug#13040][Feedback] " nobu
2016-12-20  2:33 ` [ruby-core:78733] [Ruby trunk Bug#13040] " lemsx1
2017-05-18 13:55 ` lemsx1 [this message]
2017-06-08 15:46 ` [ruby-core:81622] " lemsx1

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-64878.20170518135553.160025987cea0412@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).