Feature #13516


Improve the text of the circular require warning

Added by jaredbeck (Jared Beck) over 5 years ago. Updated over 5 years ago.

Target version:


The warning currently reads:

loading in progress, circular require considered harmful - /my/file.rb

I think it would be more helpful like:

Circular require: Loading of /my/file.rb is already in progress, but require was called again

I think this is more helpful because it clarifies that /my/file.rb is the problem.

What do you think? Thanks!

Updated by shevegen (Robert A. Heiler) over 5 years ago

I am not sure if this particular message is better or not - but I agree with you in
general. To me this was a source of frustration for a long time transitioning from
ruby 1.8.x to a higher ruby version, until I started to change the way how I write
ruby code. Nowadays I usually start with the smallest, standalone base .rb file and
then build from there to avoid the circular requires.

I still would love to see some kind of better abstraction system for loading ruby
code though, so I am all up for all suggestions that try to improve that warning
or the overall situation here.

PS: Actually on second thought, your new message confuses me too. ;)

May it actually be possible to also show some ascii message or something that
pinpoints to the problematic file at hand? Like:

-> bar/foo.rb

With the warning showing that foo.rb is required by both foobar.rb and barfoo.rb
and additionally requires barfoo.rb (and barfoo.rb also showing foo.rb). I guess
ruby can not be sure as to which file is the troublemaker but it could give some
listing as to which files exactly could be problematic, most likely. Some reporting
that is a bit similar as to how the "did_you_mean" gem indicates a possible
error or typo.
the above situation, foobar.rb

Updated by jaredbeck (Jared Beck) over 5 years ago

Thanks for the response, Robert. It would be great if the error message provided that level of detail. However, that may be difficult to implement. So, maybe we should focus on simply improving the text of the existing warning. My goal is to clarify the meaning of the file at the end of the message. I think my suggested wording achieves this, but I'm open to other suggestions.

Updated by mrkn (Kenta Murata) over 5 years ago

  • Status changed from Open to Assigned
  • Assignee set to nobu (Nobuyoshi Nakada)

Updated by matz (Yukihiro Matsumoto) over 5 years ago

  • Status changed from Assigned to Open
  • Assignee deleted (nobu (Nobuyoshi Nakada))

The update of the message is OK.


Updated by matz (Yukihiro Matsumoto) over 5 years ago

  • Status changed from Open to Assigned
  • Assignee set to nobu (Nobuyoshi Nakada)

Also available in: Atom PDF