Tuesday, August 25, 2009

Fix for "Malformed version number string java (ArgumentError)" and "Unable to determine gem name and version from ..."

The following is James Norton's workaround for issues similar to:
/path/to/jruby/lib/ruby/site_ruby/1.8/rubygems/version.rb:107:in `initialize': Malformed version number string java (ArgumentError)
  from /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/rails/vendor_gem_source_index.rb:105:in `version_for_dir'
  from /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/rails/vendor_gem_source_index.rb:47:in `refresh!'
  from /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/rails/vendor_gem_source_index.rb:45:in `each'
  from /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/rails/vendor_gem_source_index.rb:45:in `refresh!'
  from /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/rails/vendor_gem_source_index.rb:29:in `initialize'
  from /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path'
  from /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/initializer.rb:298:in `add_gem_load_paths'
  from /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/initializer.rb:132:in `process'
   ... 13 levels...
  from /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/FiXato-daemons-1.0.10.2/lib/daemons/cmdline.rb:105:in `catch_exceptions'
  from /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/FiXato-daemons-1.0.10.2/lib/daemons.rb:139:in `run'
and
Unable to determine gem name and version from '/path/to/dev/git/codegr8/vendor/gems/eventmachine-0.12.8-java'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/rails/gem_dependency.rb:45:in `from_directory_name'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/tasks/gems.rake:65:in `frozen_gems'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/tasks/gems.rake:64:in `map'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/tasks/gems.rake:64:in `frozen_gems'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/tasks/gems.rake:23
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
 /path/to/jruby/lib/ruby/1.8/monitor.rb:191:in `mon_synchronize'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
 /path/to/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:19:in `load'
James Norton's workaround is to rename the unpacked (frozen) gem directory under vendor/gems/ to remove the "-java" from the end of the name. He said that this is because the version.rb file in the gems module expects the version number at the end of the directory name.

This issue, workaround, and some further comments on this topic on the JRuby user list can be found here.

Thanks, James!

No comments: