matschaffer / win32-open3-19

DEPRECATED: Provides Open4.popen4 via win32/open3 (win32-open3 behavior from 1.8) on ruby 1.9. Don't use this for new code.
7 stars 4 forks source link

Invalid argument - java -jar #2

Open jarmo opened 12 years ago

jarmo commented 12 years ago

I'm seeing this when trying to use it with jammit's yui-compressor:

C:/Ruby193/lib/ruby/1.9.1/open3.rb:202:in `spawn': Invalid argument - java -jar C:/Ruby193/lib/ruby/gems/1.9.1/gems/yui-compressor-0.9.6/lib/yui/../yuicompresso
r-2.4.4.jar --type css --charset utf-8 (Errno::EINVAL)
        from C:/Ruby193/lib/ruby/1.9.1/open3.rb:202:in `popen_run'
        from C:/Ruby193/lib/ruby/1.9.1/open3.rb:90:in `popen3'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/win32-open3-19-0.0.1/lib/win32/open3.rb:5:in `popen4'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/POpen4-0.1.4/lib/popen4.rb:48:in `popen4'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/yui-compressor-0.9.6/lib/yui/compressor.rb:68:in `block in compress'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/yui-compressor-0.9.6/lib/yui/compressor.rb:117:in `streamify'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/yui-compressor-0.9.6/lib/yui/compressor.rb:66:in `compress'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jammit-0.6.3/lib/jammit/compressor.rb:83:in `compress_css'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jammit-0.6.3/lib/jammit/packager.rb:80:in `pack_stylesheets'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jammit-0.6.3/lib/jammit/packager.rb:43:in `block in precache_all'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jammit-0.6.3/lib/jammit/packager.rb:42:in `each'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jammit-0.6.3/lib/jammit/packager.rb:42:in `precache_all'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jammit-0.6.3/lib/jammit.rb:132:in `package!'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jammit-0.6.3/lib/jammit/command_line.rb:29:in `initialize'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jammit-0.6.3/bin/jammit:5:in `new'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jammit-0.6.3/bin/jammit:5:in `<top (required)>'
        from C:/ruby193/bin/jammit:21:in `load'
        from C:/ruby193/bin/jammit:21:in `<main>'
matschaffer commented 12 years ago

Have you tried this on 1.9.2? I'm wondering if it might be a 1.9.3 bug. I probably won't have time to test this in the next couple weeks though since I have a talk coming up, so any testing assistance you can offer is appreciated.

Thanks!

On Fri, Nov 25, 2011 at 8:33 AM, Jarmo Pertman < reply@reply.github.com

wrote:

I'm seeing this when trying to use it with jammit's yui-compressor:

   C:/Ruby193/lib/ruby/1.9.1/open3.rb:202:in `spawn': Invalid argument
  • java -jar C:/Ruby193/lib/ruby/gems/1.9.1/gems/yui-compressor-0.9.6/lib/yui/../yuicompresso r-2.4.4.jar --type css --charset utf-8 (Errno::EINVAL) from C:/Ruby193/lib/ruby/1.9.1/open3.rb:202:in popen_run' from C:/Ruby193/lib/ruby/1.9.1/open3.rb:90:in popen3' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/win32-open3-19-0.0.1/lib/win32/open3.rb:5:in popen4' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/POpen4-0.1.4/lib/popen4.rb:48:in popen4' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/yui-compressor-0.9.6/lib/yui/compressor.rb:68:in block in compress' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/yui-compressor-0.9.6/lib/yui/compressor.rb:117:in streamify' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/yui-compressor-0.9.6/lib/yui/compressor.rb:66:in compress' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jammit-0.6.3/lib/jammit/compressor.rb:83:in compress_css' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jammit-0.6.3/lib/jammit/packager.rb:80:in pack_stylesheets' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jammit-0.6.3/lib/jammit/packager.rb:43:in block in precache_all' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jammit-0.6.3/lib/jammit/packager.rb:42:in each' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jammit-0.6.3/lib/jammit/packager.rb:42:in precache_all' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jammit-0.6.3/lib/jammit.rb:132:in package!' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jammit-0.6.3/lib/jammit/command_line.rb:29:in initialize' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jammit-0.6.3/bin/jammit:5:in new' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jammit-0.6.3/bin/jammit:5:in<top (required)>' from C:/ruby193/bin/jammit:21:in load' from C:/ruby193/bin/jammit:21:in
    '

Reply to this email directly or view it on GitHub: https://github.com/matschaffer/win32-open3-19/issues/2

alanrubin commented 12 years ago

Hi,

I have the same issue with 1.9.2@p290. Using yui compressor with sprockets in a ruby project. cmd argument in open3.rb is ["java -jar C:/Ruby192/lib/ruby/gems/1.9.1/gems/yui-compressor-0.9.6/lib/yui/../yuicompressor-2.4.4.jar --type js --charset utf-8", "b"]. Any clues about that ?

Stack trace is below:

C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV_
rake aborted!
Invalid argument - java -jar C:/Ruby192/lib/ruby/gems/1.9.1/gems/yui-compressor-0.9.6/lib/yui/../yuicompressor-2.4.4.jar --type js --charset utf
  (in C:/keytree/project/app/app.js)
C:/Ruby192/lib/ruby/1.9.1/open3.rb:202:in `spawn'
C:/Ruby192/lib/ruby/1.9.1/open3.rb:202:in `popen_run'
C:/Ruby192/lib/ruby/1.9.1/open3.rb:90:in `popen3'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/win32-open3-19-0.0.1/lib/win32/open3.rb:5:in `popen4'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/POpen4-0.1.4/lib/popen4.rb:48:in `popen4'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/yui-compressor-0.9.6/lib/yui/compressor.rb:68:in `block in compress'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/yui-compressor-0.9.6/lib/yui/compressor.rb:117:in `streamify'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/yui-compressor-0.9.6/lib/yui/compressor.rb:66:in `compress'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/sprockets-2.0.2/lib/sprockets/processing.rb:265:in `block in js_compressor='
C:/Ruby192/lib/ruby/gems/1.9.1/gems/sprockets-2.0.2/lib/sprockets/processor.rb:29:in `call'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/sprockets-2.0.2/lib/sprockets/processor.rb:29:in `evaluate'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/tilt-1.3.3/lib/tilt/template.rb:76:in `render'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/sprockets-2.0.2/lib/sprockets/context.rb:175:in `block in evaluate'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/sprockets-2.0.2/lib/sprockets/context.rb:172:in `each'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/sprockets-2.0.2/lib/sprockets/context.rb:172:in `evaluate'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/sprockets-2.0.2/lib/sprockets/bundled_asset.rb:242:in `block in build_source'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/sprockets-2.0.2/lib/sprockets/caching.rb:27:in `cache_hash'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/sprockets-2.0.2/lib/sprockets/bundled_asset.rb:235:in `build_source'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/sprockets-2.0.2/lib/sprockets/bundled_asset.rb:93:in `to_s'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/sprockets-2.0.2/lib/sprockets/bundled_asset.rb:109:in `block in write_to'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/sprockets-2.0.2/lib/sprockets/bundled_asset.rb:101:in `open'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/sprockets-2.0.2/lib/sprockets/bundled_asset.rb:101:in `write_to'
C:/keytree/project/Rakefile:273:in `block (2 levels) in '
C:/Ruby192/lib/ruby/1.9.1/rake.rb:634:in `call'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:634:in `block in execute'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:629:in `each'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:629:in `execute'
C:/keytree/project/Rakefile:124:in `block (2 levels) in '
C:/Ruby192/lib/ruby/1.9.1/rake.rb:634:in `call'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:634:in `block in execute'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:629:in `each'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:629:in `execute'
C:/keytree/project/Rakefile:82:in `block (4 levels) in '
C:/keytree/project/Rakefile:80:in `each'
C:/keytree/project/Rakefile:80:in `block (3 levels) in '
C:/keytree/project/Rakefile:79:in `each'
C:/keytree/project/Rakefile:79:in `block (2 levels) in '
C:/Ruby192/lib/ruby/1.9.1/rake.rb:634:in `call'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:634:in `block in execute'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:629:in `each'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:629:in `execute'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:595:in `block in invoke_with_call_chain'
C:/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:605:in `block in invoke_prerequisites'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:602:in `each'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:602:in `invoke_prerequisites'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:594:in `block in invoke_with_call_chain'
C:/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:581:in `invoke'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2041:in `invoke_task'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2019:in `block (2 levels) in top_level'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2019:in `each'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2019:in `block in top_level'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2013:in `top_level'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:1992:in `run'
C:/Ruby192/bin/rake:31:in `
'
matschaffer commented 12 years ago

I'm pretty far removed from this code at the moment, but the trailing "b" is interesting. As is the truncated command name and a mention of app.js. Makes me wonder if this is something deeper down.

If you can set up a github repo for me that demonstrates the issue I can dig into it a bit.

matschaffer commented 12 years ago

Taking a closer look at this how did you guys manage to both get POpen4-0.1.4 and yui-compressor-0.9.6? I can't find either of those versions on rubygems.org or github.

matschaffer commented 12 years ago

Oh, whoops. Typo. Now I see https://rubygems.org/gems/yui-compressor. https://rubygems.org/gems/POpen4/versions/0.1.4-x86-mswin32. Man what a tangled web :-P

matschaffer commented 12 years ago

Okay, after a little browsing I think I see what's going on. This gem works by proxying to Ruby's built in Open3.popen3 which doesn't accept a mode as win32-open3's implementation does. So I'd say this gem isn't 100% compatible with win32-open3. Unfortunately I can't see how to specify a mode on Ruby 1.9's built in Open3.open3. Did you guys find anything out?

jarmo commented 12 years ago

I can't figure it out either. I also looked at Process.spawn where Open3.popen3 passes options forward.

matschaffer commented 12 years ago

Looks like IO.popen supports a mode argument. I get the feeling C-splunking will be necessary to figure out if/why popen3 doesn't...

matschaffer commented 12 years ago

Oh, I may have found it. Do you still have a test case for this problem? Looks like adding something like this from open3.rb might do the trick.

jarmo commented 12 years ago

I got that issue originally when i tried to use jammit on Ruby 1.9 from command line. I could try that again at some point, but not now.

jarmo commented 11 years ago

I'm still experiencing this problem on Ruby 1.9.3 and don't see that you've done any changes to the code.

jarmo commented 11 years ago

This did the trick for me when using jammit. I'm not sure if that would be correct solution for win32-open3-19 in general:

require 'open3'

module Open4
  def self.popen4(*cmd, &block)
    Open3.capture3(*cmd, :binmode => !!cmd.delete("b")) do |i, o, e, t|
      block.call(i, o, e, t.pid)
    end
  end
end