Projects

Ticket #134 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

require 'rexml/document' fails

Reported by: rebotfc@… Owned by: lsansonetti@…
Priority: major Milestone: MacRuby 0.5
Component: MacRuby Keywords:
Cc:

Description

In the course of trying to get soap4r to work I've hit this problem:

$ macirb

require 'rexml/document'

NameError: uninitialized constant REXML::Attribute::NAME_STR

from /Library/Frameworks/MacRuby.framework/Versions/0.3/usr/lib/ruby/1.9.0/rexml/attribute.rb:18:in `<class:Attribute>' from /Library/Frameworks/MacRuby.framework/Versions/0.3/usr/lib/ruby/1.9.0/rexml/attribute.rb:9:in `<module:REXML>' from /Library/Frameworks/MacRuby.framework/Versions/0.3/usr/lib/ruby/1.9.0/rexml/attribute.rb:4:in `<top (required)>' from /Library/Frameworks/MacRuby.framework/Versions/0.3/usr/lib/ruby/1.9.0/rexml/element.rb:3:in `require' from /Library/Frameworks/MacRuby.framework/Versions/0.3/usr/lib/ruby/1.9.0/rexml/element.rb:3:in `<top (required)>' from /Library/Frameworks/MacRuby.framework/Versions/0.3/usr/lib/ruby/1.9.0/rexml/document.rb:1:in `require' from /Library/Frameworks/MacRuby.framework/Versions/0.3/usr/lib/ruby/1.9.0/rexml/document.rb:1:in `<top (required)>' from (irb):1:in `require' from (irb):1 from /usr/local/bin/macirb:12:in `<main>'

Change History

  Changed 3 years ago by masterkain@…

Same on trunk

>> require 'rexml/document'
NameError: uninitialized constant REXML::Attribute::NAME_STR
	from /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.0/rexml/attribute.rb:18:in `<class:Attribute>'
	from /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.0/rexml/attribute.rb:9:in `<module:REXML>'
	from /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.0/rexml/attribute.rb:4:in `<top (required)>'
	from /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.0/rexml/element.rb:3:in `require'
	from /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.0/rexml/element.rb:3:in `<top (required)>'
	from /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.0/rexml/document.rb:1:in `require'
	from /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.0/rexml/document.rb:1:in `<top (required)>'
	from (irb):1:in `require'
	from (irb):1
	from /usr/local/bin/macirb:12:in `<main>'

  Changed 3 years ago by isc@…

Here is a reduction of the bug causing the failure:

module A
	module B
		CONST1 = "cool"
	end
	module C
		include B
	end
	class D
		include C
		CONST2 = CONST1
	end
end

Hope it'll help.

follow-up: ↓ 6   Changed 3 years ago by stephane@…

Hi, I confirm this bug in the last stable 0.4,

Hope it'll help

  Changed 3 years ago by mattaimonetti@…

As a work around, the following works:

module A
	module B
		CONST1 = "cool"
	end
	module C
		include B
	end
	class D
		include C
		CONST2 = A::B::CONST1
	end
end

  Changed 3 years ago by mattaimonetti@…

Because the constants are not inherited properly, we need to reopen the Attribute class and include the module defining the constants we are after.

You can use the following hack to get rexml working until this problem gets resolved:

require 'rexml/xmltokens'
module REXML
  class Attribute
    include ::REXML::XMLTokens
  end
end

You can put the hotpatch in a ruby file and require it before loading rexml/client or rexml/document.

- Matt

in reply to: ↑ 3   Changed 3 years ago by simonis.christophe@…

Replying to stephane@…:

Hi, I confirm this bug in the last stable 0.4, Hope it'll help

But it's works with the last snapshot of the experimental branch.

  Changed 2 years ago by lsansonetti@…

  • status changed from new to closed
  • resolution set to fixed
  • milestone set to MacRuby 0.5

I confirm that it's working with trunk. Not sure if the rest of REXML is working though.

Note: See TracTickets for help on using tickets.