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

Output of backticks call not returned but written to stdout instead #4515

Closed
til opened this issue Mar 1, 2017 · 7 comments
Closed

Output of backticks call not returned but written to stdout instead #4515

til opened this issue Mar 1, 2017 · 7 comments

Comments

@til
Copy link

til commented Mar 1, 2017

Expected Behavior

Output of command is returned from calling backticks, like in this working example on MRI (2.3.3):

$ ruby -e 'p `echo test`'
"test\n"

Actual Behavior

Output is written to stdout, and the return value of the backticks call is an empty string:

$ /opt/jruby-9.1.7.0/bin/jruby -e 'p `echo test`'
test
""

Environment

Ubuntu 16.04 / Linux 4.4.0-042stab120.6

jruby 9.1.7.0 (2.3.1) 2017-01-11 68056ae OpenJDK 64-Bit Server VM 9-internal+0-2016-04-14-195246.buildd.src on 9-internal+0-2016-04-14-195246.buildd.src +jit [linux-x86_64]

I observed this on two machines with Ubuntu 16.04 from different providers, with both jruby 9.1.6.0 and 9.1.7.0. On my local machine with ArchLinux and jruby 9.1.7.0 it behaves as expected.

Same with popen:

$ /opt/jruby-9.1.7.0/bin/jruby -e "IO.popen('echo test') { |io| p io.read }"
test
""

Verifying that output goes to stdout:

$ /opt/jruby-9.1.7.0/bin/jruby -e 'p `echo test`' > /tmp/output
$ cat /tmp/output
test
""

Is that a bug or could it be some kind of misconfiguration on the Ubuntu servers? Any hints appreciated.

@headius
Copy link
Member

headius commented Mar 1, 2017

Wow, this seems super unlikely to be broken since there are definitely backquote tests in various test suites we run. I also can't confirm what you're seeing:

$ rvm jruby-9.1.7.0 do jruby -v -e 'p `echo test`'
jruby 9.1.7.0 (2.3.1) 2017-01-11 68056ae OpenJDK 64-Bit Server VM 24.131-b16 on 1.7.0_131-b16 +jit [linux-x86_64]
"test\n"

Perhaps something's weird with your shell? I have no explanation for what you're seeing, but if either of those behaviors were actually happening we'd have dozens of broken tests.

@til
Copy link
Author

til commented Mar 1, 2017

I could reproduce it now on a fresh digitalocean instance with Ubuntu 16.04, without any additional configuration, with java installed from the package openjdk-9-jre-headless:

root@ubuntu-2gb-fra1-01:~/jruby-9.1.7.0# bin/jruby -v -e 'p `echo test`'
jruby 9.1.7.0 (2.3.1) 2017-01-11 68056ae OpenJDK 64-Bit Server VM 9-internal+0-2016-04-14-195246.buildd.src on 9-internal+0-2016-04-14-195246.buildd.src +jit [linux-x86_64]
test
""

With openjdk-8-jre-headless it works as expected:

root@ubuntu-2gb-fra1-01:~/jruby-9.1.7.0# bin/jruby -v -e 'p `echo test`'
jruby 9.1.7.0 (2.3.1) 2017-01-11 68056ae OpenJDK 64-Bit Server VM 25.121-b13 on 1.8.0_121-8u121-b13-0ubuntu1.16.04.2-b13 +jit [linux-x86_64]
"test\n"

@til
Copy link
Author

til commented Mar 3, 2017

Please excuse my ignorance regarding Java versions - since openjdk-9 packages are included in a recent Ubuntu release, I had assumed that it is a version automatically supported by jruby. On Ubuntu one should probably install the default-jdk package (or the default-jre-headless variant) instead, which depends on openjdk-8.

Downgrading openjdk works fine for me, so I'm closing this issue, feel free to reopen if openjdk-9 compatibility is desired.

@til til closed this as completed Mar 3, 2017
@enebo enebo added this to the Invalid or Duplicate milestone Mar 6, 2017
@headius
Copy link
Member

headius commented Mar 9, 2017

Actually I do want to look into those. We have not focused on JDK9 support, but we should do that soon.

@headius headius reopened this Mar 9, 2017
@headius headius modified the milestones: JRuby 9.2.0.0, JRuby 9.1.9.0 Apr 19, 2017
@headius
Copy link
Member

headius commented Apr 19, 2017

We'll do a push for Java 9 in the 9.2 cycle.

@p0deje
Copy link

p0deje commented Nov 21, 2017

I can confirm that issue exists on JRuby 9.1.14.0 + JDK 9.0.1.

@headius
Copy link
Member

headius commented Feb 28, 2018

This appears to work fine on 9.1.16.0 + Java 9.0.1. Please let us know if it's still causing problems.

@headius headius closed this as completed Feb 28, 2018
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