 |
Forums |
Admin Discussion Forums: help Start New Thread
By: Charlie Savage
RE: Freezing libxml-ruby to your rails applic [ reply ] 2009-01-12 07:10
|
Hey Matt,
Just wanted to finish off this issue. Unfortunately, I can't reproduce the problem:
Here is my test case:
require 'xml'
class CallBacks
include XML::SaxParser::Callbacks
def on_start_element(element, attributes)
puts "on_start_element"
end
end
parser = XML::SaxParser.new
parser.callbacks = CallBacks.new
parser.string = "<hi>bye</hi>"
parser.parse
And it outputs:
on_start_element
Seems like somehow you are pulling in an older version of XML::SaxParser::Callbacks that doesn't have that on_start_element_ns method defined. Is that possible?
Charlie
|
By: Matt Stuart
RE: Freezing libxml-ruby to your rails applic [ reply ] 2008-12-22 21:34
|
That's correct. It was the version I had working with 0.9.6. Ran it with the new 0.9.7 and received the error message. Changed the method declaration and it works.
Going to do a little testing on this side to make sure I'm not doing something wrong myself and that I don't have cross contamination.
|
By: Matt Stuart
RE: Freezing libxml-ruby to your rails applic [ reply ] 2008-12-22 21:12
|
I went back and read your updated documentation, excuse the ignorance :) I'll have to subscribe to the changes list.
I have the following at the top of my class:
class XmlCallbacks
include XML::SaxParser::Callbacks
Do I need the LibXML prefix to make it work?
|
By: Charlie Savage
RE: Freezing libxml-ruby to your rails applic [ reply ] 2008-12-22 21:06
|
Hey Matt,
Yes, the last update added SAX2 support. The code sees if you have on_start_element defined, and if so, calls it. Then it calls on_start_element_ns. That's now defined on this module:
LibXML::XML::SaxParser::Callbacks
If you are not using that module, then simply define the method yourself.
def on_start_element_ns(name, attributes, prefix, uri, namespaces)
end
Same thing is true for on_end_element_ns
Charlie
|
By: Matt Stuart
RE: Freezing libxml-ruby to your rails applic [ reply ] 2008-12-22 20:58
|
Your comment brings us one step closer to resolution.
The OSX install has long ago stopped being an applicable test bed for this problem so that doesn't count. But it was the original source of my git commits thus only the .bundle was there. I built the gem on the linux install which now includes the .so. It appears to be one step closer, at least it can find the library now.
Though I appear to have a new problem. I created an XMLCallbacks for use with the SaxParser and it's working fine on any install that has the gem normally installed but on this frozen version I get the following error:
NoMethodError (undefined method `on_start_element_ns' for #<XmlCallbacks:0x7f9e3a839228>):
The method is defined: def on_start_element( element, attributes )
Has something recently changed?
|
By: Charlie Savage
RE: Freezing libxml-ruby to your rails applic [ reply ] 2008-12-22 20:13
|
Well,
The file in question is libxml_ruby, which will have .so extension on windows/linux and be a bundle on OS X.
Check to see if its in the libxml-ruby/lib directory.
My guess is this still has do with the path that Ruby Gems is using to load the shared library (not the gem itself).
Charlie
|
By: Matt Stuart
RE: Freezing libxml-ruby to your rails applic [ reply ] 2008-12-22 18:42
|
So far we've tested with MacOSX, Linux, and freeBSD all 3 have the same results.
After lots of reading and trying I'm at the following point:
config/environment.rb:
ENV['GEM_PATH'] = "#{RAILS_ROOT}/vendor:#{ENV['GEM_PATH']}"
require 'rubygems'
Gem.clear_paths
(I should mention I've tried /vendor/gems, /vendor/gems/libxml-ruby-0.9.7, /vendor/gems/libxml-ruby-0.9.7/lib with no change)
And this appears to sort of work. Doing the console test of:
export GEM_PATH=<as above>
gem query
Results in the libxml-ruby-0.9.7 that I have installed.
Unfortunately this is as far as it gets. The before mentioned error still occurs.
Could I be missing the file it's looking for?
|
By: Matt Stuart
RE: Freezing libxml-ruby to your rails applic [ reply ] 2008-12-22 07:12
|
Hi Charlie,
Kevin Willock and myself are part of the same team attempting to solve this problem.
When I attempt to freeze libxml to my application by using the "gem install libxml-ruby -i .." method or "gem unpack" I get an error (it is appended below). I've added my path to the config.load paths like so:
config.load_paths += Dir["#{RAILS_ROOT}/vendor/gems/**"].map do |dir|
File.directory?(lib = "#{dir}/lib") ? lib : dir
end
Directory structure is so:
vendor/
gems/
libxml-ruby-0.9.7/
This appears to work but the error that occurs is:
MissingSourceFile (no such file to load -- libxml_ruby):
/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
...
/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:510:in `require'
/vendor/gems/libxml-ruby-0.9.7/lib/libxml.rb:12
Quite obviously it's finding my frozen gem in my /vendor path but it is unable to find the libxml_ruby required during the loading of the library.
Any tips on what file it's looking for would be extremely helpful so I can attempt to tell rails where to find it would be excellent. Thank you.
Matt Stuart
|
By: Matt Stuart
Freezing libxml-ruby to your rails applicatio [ reply ] 2008-12-19 01:15
|
I understand we require libxml2* packages to even use libxml-ruby and that's fine. Currently I need to freeze the gem itself to my application so when I deploy it I do not need to ensure that the gem is installed.
I have tried gem install -i to the vendor/gems directory of my application with some possibly wrong code in my environment.rb to try and look there first.
Has anyone tried this or have any tips? "Just gem install the gem" is not a helpful answer.
|
|
 |