All, Rails 1.1.2 Win XP Pro Rubyful Soup 1.0.4 htmltools 1.0.9 I am terribly confused as to what pulling in a gem does with respect to how many modules get loaded at runtime. I am using two gems in my app, Rubyful Soup and htmltools. RubyfulSoup requires one module from the htmltools gem (html/sgml-parser). My app requires the RubyfulSoup gem. When I started my app, something was causing _another_ module from the htmltools gem named html/tags.rb to be loaded. This eventually led to a namespace conflict. When I made local copies of both rubyful_soup.rb and sgml-parser.rb and then used only a "require" statement to do the appropriate requiring (abandoning the Gem framework), the html/tags.rb module was never loaded (which makes sense, because I couldn''t find a dependency from html/sgml-parser to html/tags in the first place). No namespace conflict. I notice that if I just try to have the local copy of rubyful_soup.rb, but let it refer to the gem-installed ''html/sgml-parser'', that tags.rb attempts to be loaded. Based on the stack trace below, what is ActiveSupport dependencies.rb doing here? Why are modules that are never even invoked being loaded for me? Thanks, Wes =============================================================I forced an error in tags.rb so that I could see whether it was trying to be loaded or not. Here is the stack trace from that load attempt: C:/ruby/lib/ruby/gems/1.8/gems/htmltools-1.09/lib/html/tags.rb:115:in `initialize'' C:/ruby/lib/ruby/gems/1.8/gems/htmltools-1.09/lib/html/tags.rb:115:in `add_tag'' C:/ruby/lib/ruby/gems/1.8/gems/htmltools-1.09/lib/html/tags.rb:218 C:/ruby/lib/ruby/gems/1.8/gems/htmltools-1.09/lib/html/tags.rb:127 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/htmltools-1.09/lib/html/tree.rb:15 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:182:in `activate'' C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:181:in `activate'' C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:26:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' #{RAILS_ROOT}/app/modules/rubyful_soup.rb:17 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' #{RAILS_ROOT}/app/models/document.rb:3 -e:4 C:/ruby/lib/ruby/gems/1.8/gems/htmltools-1.09/lib/html/tags.rb:115:in `initialize'' C:/ruby/lib/ruby/gems/1.8/gems/htmltools-1.09/lib/html/tags.rb:115:in `add_tag'' C:/ruby/lib/ruby/gems/1.8/gems/htmltools-1.09/lib/html/tags.rb:218 C:/ruby/lib/ruby/gems/1.8/gems/htmltools-1.09/lib/html/tags.rb:127 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/htmltools-1.09/lib/html/tree.rb:15 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:182:in `activate'' C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:181:in `activate'' C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:26:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' #{RAILS_ROOT}/app/modules/rubyful_soup.rb:17 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:140:in `load'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:56:in `require_or_load'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:30:in `depend_on'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:85:in `require_dependency'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:98:in `const_missing'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:in `const_missing'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:133:in `const_missing'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/cgi_process.rb:145:in `stale_session_check!'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/cgi_process.rb:107:in `session'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:887:in `assign_shortcuts_without_flash'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/flash.rb:141:in `assign_shortcuts'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:375:in `process_without_filters'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:377:in `process_without_session_management_support'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session_management.rb:117:in `process'' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/dispatcher.rb:38:in `dispatch'' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:115:in `handle_dispatch'' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:81:in `service'' C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' C:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'' C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'' C:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'' C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'' C:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'' C:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:67:in `dispatch'' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/servers/webrick.rb:59 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/server.rb:30 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' script/server:3 C:/ruby/lib/ruby/gems/1.8/gems/htmltools-1.09/lib/html/tags.rb:115:in `initialize'' C:/ruby/lib/ruby/gems/1.8/gems/htmltools-1.09/lib/html/tags.rb:115:in `add_tag'' C:/ruby/lib/ruby/gems/1.8/gems/htmltools-1.09/lib/html/tags.rb:218 C:/ruby/lib/ruby/gems/1.8/gems/htmltools-1.09/lib/html/tags.rb:127 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/htmltools-1.09/lib/html/tree.rb:15 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:182:in `activate'' C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:181:in `activate'' C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:26:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' #{RAILS_ROOT}/app/modules/rubyful_soup.rb:17 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' #{RAILS_ROOT}/app/models/document.rb:3 C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:140:in `load'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:56:in `require_or_load'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:30:in `depend_on'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:85:in `require_dependency'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:98:in `const_missing'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:in `const_missing'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:133:in `const_missing'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/cgi_process.rb:145:in `stale_session_check!'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/cgi_process.rb:107:in `session'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:887:in `assign_shortcuts_without_flash'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/flash.rb:141:in `assign_shortcuts'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:375:in `process_without_filters'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:377:in `process_without_session_management_support'' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session_management.rb:117:in `process'' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/dispatcher.rb:38:in `dispatch'' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:115:in `handle_dispatch'' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:81:in `service'' C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' C:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'' C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'' C:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'' C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'' C:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'' C:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:67:in `dispatch'' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/servers/webrick.rb:59 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/server.rb:30 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' script/server:3 -e:4 This error occured while loading the following files: document.rb ./script/../config/../app/modules/rubyful_soup.rb html/sgml-parser.rb html/tree html/tags -- Posted via http://www.ruby-forum.com/.
Wes Gamble
2006-May-18 22:17 UTC
[Rails] Re: Unnecessary Gem modules loaded under Rails 1.1.2
I''ve located the gemspec for htmltools - here it is: Gem::Specification.new do |s| s.name = %q{htmltools} s.version = "1.09" s.date = %q{2004-09-10} s.summary = %q{This is a Ruby library for building trees representing HTML structure.} s.email = %q{johannes@brodwall.com} s.homepage = %q{http://ruby-htmltools.rubyforge.org/} s.autorequire = %q{html/tree} s.bindir = nil s.has_rdoc = nil s.platform = nil s.files = ["demo/degolive.rb", "demo/ebaySearch.rb", "demo/xpath.rb", "INSTALL", "lib/html/element.rb", "lib/html/rexml-nodepath.rb", "lib/html/sgml-parser.rb", "lib/html/stparser.rb", "lib/html/tags.rb", "lib/html/tree.rb", "lib/html/xmltree.rb", "lib/html/xpath.rb", "README", "test/tc_html-element.rb", "test/tc_html-tree.rb", "test/tc_stacking-parser.rb", "test/tc_xpath.rb", "test/suite.rb"] s.test_files = ["test/suite.rb"] end I assume that "s.autorequire = %q{html/tree}" means that this will automatically be loaded whenever any part of the Gem is loaded. (The tree.rb file loads the tags.rb file which was causing my namespace collision.) Is that correct? Wes -- Posted via http://www.ruby-forum.com/.