Parse_input exception when gem is executed in a different directory

Hi,

This exception completely baffles me. I am working with autotest to
make it
JRuby compatible. So I have the trunk checked out and when I execute it
from the local directory it runs fine. But, when I copy it to my gems
directory (/usr/local/share/jruby/lib/ruby/gems/1.8/gems/) and try to
run it
like a normal gem it throws this exception.

/usr/local/share/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/lib/unit_diff.rb:70:in
parse_input': No such file or directory - File not found - -u (Errno::ENOENT) from /usr/local/share/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/lib/unit_diff.rb:183:inunit_diff’
from
/usr/local/share/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/lib/unit_diff.rb:56:in
unit_diff' from /usr/local/share/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/bin/unit_diff:38 from /usr/local/share/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/ZenTest-4.0.0/bin/unit_diff:19:inload’
from /usr/local/share/jruby/bin/unit_diff:19

The only difference in the codebase is this line:
In Gem directory:
self.unit_diff = “#{ruby} -I#{File.dirname(FILE)} -S unit_diff -u”

In local directory:
self.unit_diff = “#{ruby} -I#{File.dirname(FILE)}
/home/josh/code/zentest/bin/unit_diff -u”

I change this line because when it is in the local directory I want it
to
run the local copy, not the gem copy.

The trouble line of code is this:
while line = input.gets

The input object is the ARGF object.

Can anybody tell me what is going own? Thanks so much for all help and
suggestions

Josh M.

Josh M. wrote:

The only difference in the codebase is this line:
In Gem directory:
self.unit_diff = “#{ruby} -I#{File.dirname(FILE)} -S unit_diff -u”

Ok, what’s likely happening here is that we’re trying to run the
separate JRuby instance in the same JVM and probably not processing the
commands correctly.

What does the code use this unit_diff line for? Is it popening or
forking or something?

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

After reviewing the code this is the command that actually starts the
sub
processes.
open("| #{cmd}", “r”) do |f|

end

These are the to commands that get passed to it:
This is when it is in the gem and does not work:
/usr/local/share/jruby/bin/jruby -X+O -I.:lib:test -rtest/unit -e
“%w[test/functional/twitter_users_controller_test.rb
test/unit/tweet_base_test.rb test/integration/connect_to_twitter_test.rb
test/unit/tweet_feed_test.rb
test/functional/tweet_feeds_controller_test.rb
test/unit/twitter_user_test.rb].each { |f| require f }” |
/usr/local/share/jruby/bin/jruby -X+O -I./…/zentest/lib -S unit_diff -u

This one is when it is in a development directory and does work:
/usr/local/share/jruby/bin/jruby -X+O -I.:lib:test -rtest/unit -e
“%w[test/functional/twitter_users_controller_test.rb
test/unit/tweet_base_test.rb test/integration/connect_to_twitter_test.rb
test/unit/tweet_feed_test.rb
test/functional/tweet_feeds_controller_test.rb
test/unit/twitter_user_test.rb].each { |f| require f }” |
/usr/local/share/jruby/bin/jruby -X+O -I./…/zentest/lib
/home/josh/code/zentest/bin/unit_diff -u

I have even tried the gem command like this and it still does not work:
/usr/local/share/jruby/bin/jruby -X+O -I.:lib:test -rtest/unit -e
“%w[test/functional/twitter_users_controller_test.rb
test/unit/tweet_base_test.rb test/integration/connect_to_twitter_test.rb
test/unit/tweet_feed_test.rb
test/functional/tweet_feeds_controller_test.rb
test/unit/twitter_user_test.rb].each { |f| require f }” |
/usr/local/share/jruby/bin/jruby -X+O -I./…/zentest/lib
/usr/local/share/jruby/bin/unit_diff -u

I am still not sure what the difference is and what is going wrong so
thanks
once again for the help.

Josh

On Fri, Mar 13, 2009 at 12:45 AM, Charles Oliver N. <

Josh M. wrote:

This one is when it is in a development directory and does work:
/usr/local/share/jruby/bin/jruby -X+O -I./…/zentest/lib
/home/josh/code/zentest/bin/unit_diff -u

I have even tried the gem command like this and it still does not work:
/usr/local/share/jruby/bin/jruby -X+O -I./…/zentest/lib
/usr/local/share/jruby/bin/unit_diff -u

I am still not sure what the difference is and what is going wrong so
thanks once again for the help.

I’ve pared this down to the only differences, which are the location and
method of running unit_diff (must be something installed along with
zentest, I assume). And there are no differences in the two unit_diff
scripts at all?

I don’t see anything obvious here that would make it not work correctly.
Obviously in one case it’s passing -u to unit_diff and in the other case
it’s passing it to jruby. The open with “| …” is essentially
equivalent in JRuby to doing popen “…”, and I’m pretty sure popen
should handle these commands ok.

Can you triple-check that the gem version is actually the dev gem you
installed? I know that’s the most obvious question, but indulge me. I
don’t see why it wouldn’t work once installed as a gem.

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hello,

I figured it out. Actually the problem was the “-u” not being passed to
the
right place. When I added -ws to the command it works great (“jruby -ws
-S
unit_diff -u”). Thanks for the help and the suggestion to use the Jruby
object to turn own the objectspace. I will submit a patch soon that
should
make the next version of ZenTest JRuby read!

Thanks,

Josh

On Sat, Mar 14, 2009 at 12:25 AM, Charles Oliver N. <

Josh M. wrote:

Hello,

I figured it out. Actually the problem was the “-u” not being passed to
the right place. When I added -ws to the command it works great (“jruby
-ws -S unit_diff -u”). Thanks for the help and the suggestion to use the
Jruby object to turn own the objectspace. I will submit a patch soon
that should make the next version of ZenTest JRuby read!

Oh right! Because otherwise unit_diff is looking for -u to be a file to
diff, rather than an argument. Good find! Let us know how it goes.

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email