Freezing gems that contain jars

I was trying to unpack gems into my rails project and I noticed gems
that
contain jars like “hpriocot” and “jrubyopenssl” weren’t unpacking into
“vendor/gems”. Is there some limitation on this or am I just doing
something
stupid ? Is it just a weird issue with hpricot, since the jdbc gems seem
to
unpack just fine.
I noticed in my original gem directory hpricot is called
“hpricot-0.6.164-java”,
could that be effecting it also?

This is in my environment.rb

  • config.gem “hpricot”, :version => ‘0.6.164’ *
    config.gem “memcache-client”, :version => ‘1.7.2’
    config.gem “soap4r”, :version => ‘1.5.8’
  • config.gem “jruby-openssl”, :version => ‘0.5’*
    config.gem “rails”, :version => ‘2.2.2’
    config.gem “activerecord-jdbcmysql-adapter”, :version => ‘0.9.1’
    config.gem “activerecord-jdbc-adapter”, :version => ‘0.9.1’
    config.gem “jdbc-mysql”, :version => ‘5.0.4’

~Matt

On Wed, Jun 24, 2009 at 12:13 AM, Matthew K.
[email protected]wrote:

  • config.gem “hpricot”, :version => ‘0.6.164’ *
    config.gem “memcache-client”, :version => ‘1.7.2’
    config.gem “soap4r”, :version => ‘1.5.8’
  • config.gem “jruby-openssl”, :version => ‘0.5’*
    config.gem “rails”, :version => ‘2.2.2’
    config.gem “activerecord-jdbcmysql-adapter”, :version => ‘0.9.1’
    config.gem “activerecord-jdbc-adapter”, :version => ‘0.9.1’
    config.gem “jdbc-mysql”, :version => ‘5.0.4’

Are there any messages printed out when you try to freeze the gems?

/Nick

jruby -S rake gems:unpack
No output, I noticed jruby-openssl is fine, so I assume its just a
naming
issue with hpricot. In my gems folder is called “hpricot-0.6.164-java”.
Does
that mean I should change my config?

config.gem “hpricot”, :version => ‘0.6.164’ * nothing happens, so I
would assume this should work
*
*

  • config.gem “hpricot-java”, :version => ‘0.6.164’ ERROR: could not
    find gem hpricot-java locally or in a repository
  • config.gem “hpricot”, :version => ‘0.6.164-java’ * Illformed
    requirement
    [“0.6.164-java”]*

~Matt

On Jun 24, 2009, at 00:27 , Matthew K. wrote:

config.gem “hpricot”, :version => ‘0.6.164-java’ * Illformed
requirement [“0.6.164-java”]

Ok, that helps. My best guess is that the Rails gem dependency code or
Rubygems is not resolving the platform properly. Can you try this –
try the following code in the Rails console and see what it gives you:

puts Rails::GemDependency.new(‘hpricot’, :version =>
‘0.6.164’).send(:specification).to_ruby

/Nick

Another issue to be aware of: if you’re wrapping up your entire app into
a
jar, then loading classes from jars-within-jars isn’t going to work.
(Sorry
I can’t tell from the context of your post if you’re doing this or not)
http://jira.codehaus.org/browse/JRUBY-3299

Yeah, so it looks like it is finding hpricot ok, platform and all. At
this
point I’m not sure what’s happening. Maybe you can instrument the Rails
rake
tasks and gem dependency code with puts and/or rescues to see where it
might
be going wrong.

/Nick

Hrmm the platform does say jruby

Loading development environment (Rails 2.2.2)

puts Rails::GemDependency.new(‘hpricot’, :version =>
‘0.6.164’).send(:specification).to_ruby

-- encoding: utf-8 --

Gem::Specification.new do |s|
s.name = %q{hpricot}
s.version = “0.6.164”
s.platform = %q{jruby}

s.required_rubygems_version = Gem::Requirement.new(“>= 0”) if
s.respond_to? :required_rubygems_version=
s.authors = [“why the lucky stiff”]
s.date = %q{2008-10-30}
s.description = %q{a swift, liberal HTML parser with a fantastic
library}
s.email = %q{[email protected] [email protected]}
s.extra_rdoc_files = [“README”, “CHANGELOG”, “COPYING”]
s.files = [“CHANGELOG”, “COPYING”, “README”, “Rakefile”,
“test/test_paths.rb”, “test/test_preserved.rb”, “test/test_parser.rb”,
“test/files”, “test/load_files.rb”, “test/test_builder.rb”,
“test/test_xml.rb”, “test/test_alter.rb”, “test/files/cy0.html”,
“test/files/pace_application.html”, “test/files/basic.xhtml”,
“test/files/utf8.html”, “test/files/boingboing.html”,
“test/files/week9.html”, “test/files/tenderlove.html”,
“test/files/immob.html”, “test/files/why.xml”,
“test/files/uswebgen.html”,
“lib/hpricot”, “lib/hpricot.rb”, “lib/hpricot/tags.rb”,
“lib/hpricot/builder.rb”, “lib/hpricot/traverse.rb”,
“lib/hpricot/elements.rb”, “lib/hpricot/modules.rb”,
“lib/hpricot/inspect.rb”, “lib/hpricot/tag.rb”,
“lib/hpricot/blankslate.rb”,
“lib/hpricot/xchar.rb”, “lib/hpricot/htmlinfo.rb”,
“lib/hpricot/parse.rb”,
“extras/mingw-rbconfig.rb”, “ext/hpricot_scan/hpricot_scan.h”,
“ext/hpricot_scan/hpricot_gram.h”,
“ext/hpricot_scan/HpricotScanService.java”,
“ext/fast_xs/FastXsService.java”, “ext/hpricot_scan/hpricot_scan.c”,
“ext/hpricot_scan/hpricot_gram.c”, “ext/fast_xs/fast_xs.c”,
“ext/hpricot_scan/test.rb”, “ext/hpricot_scan/extconf.rb”,
“ext/fast_xs/extconf.rb”, “ext/hpricot_scan/hpricot_scan.rl”,
“ext/hpricot_scan/hpricot_scan.java.rl”,
“ext/hpricot_scan/hpricot_common.rl”,
“lib/universal-java1.6/hpricot_scan.jar”,
“lib/universal-java1.6/fast_xs.jar”]
s.homepage = %q{http://code.whytheluckystiff.net/hpricot/}
s.rdoc_options = [“–quiet”, “–title”, “The Hpricot Reference”,
“–main”,
“README”, “–inline-source”]
s.require_paths = [“bin”, “lib/universal-java1.6”, “lib”]
s.rubygems_version = %q{1.3.3}
s.summary = %q{a swift, liberal HTML parser with a fantastic library}

if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 2

if Gem::Version.new(Gem::RubyGemsVersion) >= 

Gem::Version.new(‘1.2.0’)
then
else
end
else
end
end
=> nil

So I came up with a hacky solution, I’ll share incase someone else runs
into
this.

  1. Manually copied hpricot-java into vendor/gems
  2. Had to rename hpricot-java to hpricot since rails didn’t like java in
    the
    version
  3. Had to move the hpricot_scan.jar since when it was frozen it couldn’t
    find it, since it was in some universal java directory. Not sure why
    rubygems is fine with this, but when rails does it, its not fine.

no such file to load – hpricot_scan
//jruby-1.3.1/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
require' //jruby-1.3.1/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in require’
/Users/hyper/sidusa/cms_auth_b4/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in
require' /Users/hyper/sidusa/cms_auth_b4/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in new_constants_in’
/Users/hyper/sidusa/cms_auth_b4/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in
require' /Users/hyper/sidusa/cms_auth_b4/vendor/gems/hpricot-0.6.164/lib/hpricot.rb:20 /Users/hyper/sidusa/cms_auth_b4/vendor/gems/hpricot-0.6.164/lib/hpricot.rb:31:in require’

~Matt