circular require considered harmful
rochefort opened this issue · 3 comments
rochefort commented
a warning occured with -w
option.
irb -w
>> require 'unicode/display_width'
/Users/trsw/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/unicode-display_width-1.0.2/lib/unicode/display_width/string_ext.rb:1: warning: loading in progress, circular require considered harmful - /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/unicode-display_width-1.0.2/lib/unicode/display_width.rb
from /Users/trsw/.rbenv/versions/2.3.0/bin/irb:11:in `<main>'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/2.3.0/irb.rb:394:in `start'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/2.3.0/irb.rb:394:in `catch'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/2.3.0/irb.rb:395:in `block in start'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/2.3.0/irb.rb:485:in `eval_input'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/2.3.0/irb/ruby-lex.rb:231:in `each_top_level_statement'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/2.3.0/irb/ruby-lex.rb:231:in `catch'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/2.3.0/irb/ruby-lex.rb:232:in `block in each_top_level_statement'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/2.3.0/irb/ruby-lex.rb:232:in `loop'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/2.3.0/irb/ruby-lex.rb:246:in `block (2 levels) in each_top_level_statement'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/2.3.0/irb.rb:486:in `block in eval_input'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/2.3.0/irb.rb:623:in `signal_status'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/2.3.0/irb.rb:489:in `block (2 levels) in eval_input'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/2.3.0/irb/context.rb:380:in `evaluate'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/2.3.0/irb/workspace.rb:87:in `evaluate'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/2.3.0/irb/workspace.rb:87:in `eval'
from (irb):1:in `irb_binding'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `rescue in require'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `require'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/unicode-display_width-1.0.2/lib/unicode/display_width.rb:31:in `<top (required)>'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/unicode-display_width-1.0.2/lib/unicode/display_width.rb:31:in `require_relative'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/unicode-display_width-1.0.2/lib/unicode/display_width/string_ext.rb:1:in `<top (required)>'
from /Users/trsw/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/unicode-display_width-1.0.2/lib/unicode/display_width/string_ext.rb:1:in `require_relative'
I think this line is needless.
lib/unicode/display_width/string_ext.rb
require_relative '../display_width'
janlelis commented
Since it is a possible entry-point to the library, this require statement is necessary, but I put an additional check there to avoid the warning.
rochefort commented
If you don't mind, could you release v1.0.3 because I'm developing gems using unicode-display_width?
janlelis commented
You are right, I just pushed it to RubyGems.