Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ant integration: rakeimport throws NilClass #1656

Closed
inger opened this issue Apr 24, 2014 · 3 comments
Closed

ant integration: rakeimport throws NilClass #1656

inger opened this issue Apr 24, 2014 · 3 comments

Comments

@inger
Copy link

inger commented Apr 24, 2014

Minimal test file: /tmp/jrubyant/build.xml:

<project name="rakebug"  basedir=".">
  <property name="build.jruby.version"     value="1.7.12"/> 
  <path id="jruby-complete">
      <fileset file="jruby-complete-${build.jruby.version}.jar"/>
  </path>
  <taskdef name="rakeimport" classname="org.jruby.ant.RakeImport" classpathref="jruby-complete"/>
  <rakeimport/>
</project>

An 'ant build' there yields:

[rakeimport] NoMethodError: undefined method `split' for nil:NilClass
[rakeimport]   location_from_caller at file:/tmp/jrubyant/jruby-complete-1.7.12.jar!/META-INF/jruby.home/lib/ruby/shared/ant/ant.rb:168
[rakeimport]             initialize at file:/tmp/jrubyant/jruby-complete-1.7.12.jar!/META-INF/jruby.home/lib/ruby/shared/ant/ant.rb:23
[rakeimport]                 import at file:/tmp/jrubyant/jruby-complete-1.7.12.jar!/META-INF/jruby.home/lib/ruby/shared/ant/tasks/raketasks.rb:26

BUILD FAILED
/tmp/jrubyant/build.xml:10: Build failed: (NoMethodError) undefined method `split' for nil:NilClass

With Jruby 1.5.6, it just complains about the missing Rakefile (expected).
The next version I tried is 1.6.8 - there it already fails.

@imella
Copy link

imella commented Aug 21, 2014

I'm having the same issue using JRuby 1.7.10 when trying to invoke rake tasks from a Rails project.
With using JRuby 1.5.6 it complains about the ruby version (1.8.7), but that's only because it's a Rails 4 app and it requires a version >= 1.9.3 (expected)

@djha-skin
Copy link

I'm having the same issue.

When I run fpm in jruby 1.7.18, I get the error shown below. I do not get the same error when running fpm on normal ruby 1.9 .

$ /tmp/jruby/jruby-1.7.18/bin/fpm -s gem -t deb fpm
NoMethodError: undefined method `split' for nil:NilClass
  install_to_staging at /tmp/jruby/jruby-1.7.18/lib/ruby/gems/shared/gems/fpm-1.3.3/lib/fpm/package/gem.rb:190
               input at /tmp/jruby/jruby-1.7.18/lib/ruby/gems/shared/gems/fpm-1.3.3/lib/fpm/package/gem.rb:56
             execute at /tmp/jruby/jruby-1.7.18/lib/ruby/gems/shared/gems/fpm-1.3.3/lib/fpm/command.rb:332
                each at org/jruby/RubyArray.java:1613
             execute at /tmp/jruby/jruby-1.7.18/lib/ruby/gems/shared/gems/fpm-1.3.3/lib/fpm/command.rb:331
                 run at /tmp/jruby/jruby-1.7.18/lib/ruby/gems/shared/gems/clamp-0.6.3/lib/clamp/command.rb:67
                 run at /tmp/jruby/jruby-1.7.18/lib/ruby/gems/shared/gems/fpm-1.3.3/lib/fpm/command.rb:510
                 run at /tmp/jruby/jruby-1.7.18/lib/ruby/gems/shared/gems/clamp-0.6.3/lib/clamp/command.rb:125
              (root) at /tmp/jruby/jruby-1.7.18/lib/ruby/gems/shared/gems/fpm-1.3.3/bin/fpm:8
                load at org/jruby/RubyKernel.java:1087
              (root) at /tmp/jruby/jruby-1.7.18/bin/fpm:23

The offending line:

      gem_bin  = gem_env.select{ |line| line =~ /EXECUTABLE DIRECTORY/ }.first.split(': ').last

@headius
Copy link
Member

headius commented Jan 7, 2015

I think we have a few issues running together here.

The original report (by @inger) was against 1.6.8, and eventually falls into ant/ant.rb where it tries this:

file, line = caller.detect{|el| el !~ /^#{File.dirname(__FILE__)}/ && el !~ /\.java:/}.split(/:(\d+):?/)

FILE when running from a complete JRuby jar would be something like jar:file:blah.jar!/ant/ant.rb or classpath:ant/ant.rb. If dirname works, it would remove everything after the last /. Then it would compare with caller entries to find the first one that matches.

This is likely a old bug in File.dirname's handling of URLs...that is fixed on current JRuby 1.7.

The second report in here (by @imella) is about being unable to run rake tasks from a Rails project. Unless it's very unusual, that case would usually not be running from the complete jar, and so it is likely a different-but-similar issue. Even if it is the same issue, the File.dirname fixes I mentioned came after 1.7.10, so it needs a re-test.

The third report (by @djhaskin987) is again similar, but does not appear to involve dirname or a complete JRuby jar. This is likely another different-but-similar issue.

I'm going to close this, because I believe the original issue should be fixed.

@inger: Please retest with JRuby 1.7.18 and reopen if it still exhibits the problem.

@imella: Please retest with JRuby 1.7.18 and open a new bug if it still exhibits the problem.

@djhaskin987: Please open a new bug. You're the lucky one that has a current reproduction :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants