Bug 1478833 - Ruby shebang interpreter misinterpretation
Ruby shebang interpreter misinterpretation
Status: NEW
Product: Red Hat Software Collections
Classification: Red Hat
Component: ruby (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: 3.2
Assigned To: ruby maint
BaseOS QE - Apps
Depends On:
  Show dependency treegraph
Reported: 2017-08-07 05:01 EDT by Joe Orton
Modified: 2018-02-28 05:44 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
Ruby 13786 None None None 2017-08-07 13:18 EDT

  None (edit)
Description Joe Orton 2017-08-07 05:01:59 EDT
Description of problem:
The Ruby executable interpreters the shebang line in a way which prevents use of ruby within a shebang, with the fixed scl for bug 1372700.  

Version-Release number of selected component (if applicable):
seen with all of ruby193/200/22/24

How reproducible:

Steps to Reproduce:
$ cat <<EOF > foo
> #!/usr/bin/scl enable rh-ruby22 -- ruby
> puts 'Hello, Brave New World.'
$ chmod +x foo
$ ./foo 

Actual results:
/opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- uby (LoadError) from
/opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'

Expected results:
Hello, Brave New World

Additional info:
equivalent without scl enable fix, 
scl enable rh-ruby22 -- ruby < ./foo

.. has the same behaviour.
Comment 2 Vít Ondruch 2017-08-07 12:32:55 EDT
Actually, I can reproduce it on my Fedora without SCL:

$ cat <<EOF > foo
> #!/usr/bin/scl enable rh-ruby22 -- ruby

$ ruby foo
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- uby (LoadError)
	from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'

So this is some misbehavior of Ruby parser it seems :/

$ rpm -q ruby

Note You need to log in before you can comment on or make changes to this bug.