Skip to content

system does not support options in JRuby yet: {:out=>"/dev/null", :err=>[:child, :out]} #6113

Open

Description

@eregon

Environment Information

Provide at least:

  • JRuby 9.2.11.0
  • Operating system: Ubuntu 18.04

This is notably used in RubyGems:
https://github.com/rubygems/rubygems/runs/492299454?check_suite_focus=true

/home/runner/work/rubygems/rubygems/lib/rubygems/util.rb:64: warning: system does not support options in JRuby yet: {:out=>"/dev/null", :err=>[:child, :out]}
/home/runner/work/rubygems/rubygems/lib/rubygems/util.rb:64: warning: system does not support options in JRuby yet: {:out=>"/dev/null", :err=>[:child, :out]}

Could you implement those? They seem particularly simple and often-used options.

Maybe this also relates to the error in that run?

ERROR during server thread: Bad file descriptor - No message available
Errno::EBADF: Bad file descriptor - No message available
                  close at org/jruby/RubyIO.java:1990
                   each at org/jruby/RubyArray.java:1809
  cleanup_shutdown_pipe at /home/runner/.rubies/jruby-9.2.11.0/lib/ruby/stdlib/webrick/server.rb:341
                  start at /home/runner/.rubies/jruby-9.2.11.0/lib/ruby/stdlib/webrick/server.rb:204
                  start at /home/runner/.rubies/jruby-9.2.11.0/lib/ruby/stdlib/webrick/server.rb:32
                  start at /home/runner/.rubies/jruby-9.2.11.0/lib/ruby/stdlib/webrick/server.rb:157
       start_ssl_server at /home/runner/work/rubygems/rubygems/test/rubygems/test_gem_remote_fetcher.rb:1082

Activity

  1. deivid-rodriguez commented on Mar 7, 2020

    @deivid-rodriguez
    Contributor

    The second issue has been happening intermittently for a while for us. I think it's something with jruby-openssl? This is the rubygems issue with some example failing workflows: ruby/rubygems#3105.

  2. headius commented on Mar 7, 2020

    @headius
    Member

    Some of these redirect limitations are due to posix_spawn having a limited set of options for redirecting. We do not use a fork+exec model due to the inability to do so safely from managed code, so we don't have an intermediate phase where we've forked safely away from the parent but have not yet exec'ed the child.

    The :out is unlikely to be the problem, since it's a simple file redirect... I suspect it's the :err => [:child, :out] that's unsupported.

  3. headius commented on Mar 7, 2020

    @headius
    Member

    The EBADF is likely because we're not quite right on how we handle multiple closes of the same IO; CRuby seems to allow more such situations to silently "re-close" the same IO where we raise EBADF. Will have to look into this as well.

  4. headius commented on Mar 7, 2020

    @headius
    Member

    Hmmm, a simple attempt to reproduce does not appear to produce any warnings:

    [] ~/projects/rubygems $ rvm jruby-9.2.10.0 do jruby -e 'system("ls", :out => "test.txt", :err => [:child, :out])'
    
    [] ~/projects/rubygems $ head test.txt
    CODE_OF_CONDUCT.md
    CONTRIBUTING.md
    Gemfile
    Gemfile.lock
    History.txt
    LICENSE.txt
    MAINTAINERS.txt
    MIT.txt
    Manifest.txt
    POLICIES.md
    
  5. headius commented on Mar 7, 2020

    @headius
    Member

    Can't reproduce on Ubuntu 18.04:

    $ jruby -v
    jruby 9.2.11.0-SNAPSHOT (2.5.7) 2020-02-29 fffffff OpenJDK 64-Bit Server VM GraalVM CE 20.0.0 25.242-b06-jvmci-20.0-b02 on 1.8.0_242-b06 +jit [linux-x86_64]
    $ jruby -e 'system("ls", out: "test.txt", err: [:child, :out])'
    $ head test.txt
    antlib
    appveyor.yml
    azure-pipelines.yml
    bench
    bin
    BSDL
    BUILDING.md
    CODE_OF_CONDUCT.md
    COPYING
    core
    
  6. headius commented on Mar 7, 2020

    @headius
    Member

    This warning appears to happen only if system is unable to use native process execution. That should not be the case on Ubuntu, so I wonder if there's something wrong with the JRuby install for this case.

    [] ~/projects/jruby $ jruby -v
    jruby 9.2.11.0 (2.5.7) 2020-03-02 612d7a05a6 OpenJDK 64-Bit Server VM 25.222-b10 on 1.8.0_222-b10 +jit [darwin-x86_64]
    
    [] ~/projects/jruby $ jruby -Xnative.enabled=false -e 'system("ls", :out => "test.txt", :err => [:child, :out])'
    -e:1: warning: system does not support options in JRuby yet: {:out=>"test.txt", :err=>[:child, :out]}
    
  7. eregon commented on Mar 8, 2020

    @eregon
    ContributorAuthor

    Is there a way to print the native backend? I'll try to reproduce in GitHub Actions, indeed locally it works for me too on Linux.

  8. eregon commented on Mar 8, 2020

    @eregon
    ContributorAuthor

    I cannot reproduce directly in setup-ruby's CI: https://github.com/ruby/setup-ruby/runs/493299557?check_suite_focus=true

  9. eregon commented on Mar 8, 2020

    @eregon
    ContributorAuthor

    The warning occurs at

    rubygems/test/rubygems/test_gem_ext_cmake_builder.rb:15: warning: system does not support options in JRuby yet: {:out=>"/dev/null", :err=>[:child, :out]}
    

    But that shouldn't even execute in CI:
    https://github.com/rubygems/rubygems/blob/baebef66cecc68649c386038055e62019479b5c8/test/rubygems/test_gem_ext_cmake_builder.rb#L13-L15

    skip "CmakeBuilder doesn't work on JRuby." if Gem.java_platform? && ENV["CI"]

    so that check must fail for some reason, either $CI is unset or Gem.java_platform? returns false.

    Looks like the $CI env var is not set in GitHub Actions:
    https://github.com/ruby/setup-ruby/runs/493307400?check_suite_focus=true

    @deivid-rodriguez Should we just change the check to just if Gem.java_platform? ?

    @headius How can we find out why JRuby doesn't use a native platform in that case?
    Should JRuby raise or warn when not using a native platform? IIRC that was the source of many confusing bugs like this one.

  10. eregon commented on Mar 8, 2020

    @eregon
    ContributorAuthor

    Issue for GitHub Actions to add a CI env var: https://github.com/actions/virtual-environments/issues/520

  11. deivid-rodriguez commented on Mar 8, 2020

    @deivid-rodriguez
    Contributor

    @deivid-rodriguez Should we just change the check to just if Gem.java_platform? ?

    That makes sense to me, yeah. The problem seems independent from being in a CI environment.

  12. headius commented on May 26, 2020

    @headius
    Member

    I've made a first pass at implementing the options we can support in non-native Kernel#system at #6241. Mostly this means chdir and a few specific forms of redirection.

  13. 14 remaining items

  14. added this to the JRuby 9.4.3.0 milestone on Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions