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

Failing "-x" command line option #4536

Closed
donv opened this issue Mar 17, 2017 · 2 comments

Comments

@donv
Copy link
Member

commented Mar 17, 2017

Given a script mixed_script:

#!/bin/sh
echo 'bash part'
'exec' "ruby" '-x' "$0" "$@"
#!ruby
puts 'ruby part'

Run with

./mixed_script

With MRI installed as current Ruby this produces

bash part
ruby part

With JRuby this produces

bash part
jruby: no Ruby script found in input (LoadError)

Environment

Darwin Gratass.local 16.4.0 Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64
jruby 9.1.8.0 (2.3.1) 2017-03-06 90fc7ab Java HotSpot(TM) 64-Bit Server VM 25.112-b16 on 1.8.0_112-b16 +jit [darwin-x86_64]
jruby 9.1.5.0 (2.3.1) 2016-09-07 036ce39 Java HotSpot(TM) 64-Bit Server VM 25.112-b16 on 1.8.0_112-b16 +jit [darwin-x86_64]
jruby 1.7.26 (1.9.3p551) 2016-08-26 69763b8 on Java HotSpot(TM) 64-Bit Server VM 1.8.0_112-b16 +jit [darwin-x86_64]

@donv donv added the application label Mar 18, 2017

@donv

This comment has been minimized.

Copy link
Member Author

commented Mar 20, 2017

I could use some help with this. Is is preventing my next deployment.

I can find where the error message comes from:

throw new MainExitException(1, "jruby: no Ruby script found in input (LoadError)");

This is based on RubyInstanceConfig#hasShebangLine which is set here:

That is in RubyInstanceConfig#parseShebangOptions, but I cannot find where this is called. Maybe nowhere?

@kschoelhorn

This comment has been minimized.

Copy link
Contributor

commented Mar 20, 2019

I also just stumbled upon this (exactly two years later 😁).

The option probably broke with the fix for #3294: In the first pass doProcessArguments, parseShebangOptions, and finally setHasShebangLine was called, so hasShebangLine returned true afterwards. There is event a test for it, but it seems it is not run?

I have a fix in the making, will open a PR if it is finished.

kschoelhorn added a commit to kschoelhorn/jruby that referenced this issue Mar 21, 2019

Fix -x command line option to skip header
The -x option has been broken since [1], as parseShebangOptions is no
longer run, which is responsible for calling setHasShebangLine. As this
is no longer done, hasShebangLine always returns false, even if there is
a valid shebang.

The fix is to remove the check at this location and move it into the
findScript function, which already searches for the ruby shebang.

[1]: 9e2d6dc

Fix: jruby#4536

@headius headius closed this in 4081dd9 Apr 9, 2019

@enebo enebo added this to the JRuby 9.2.8.0 milestone Aug 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.