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)
rh-ruby24
Unspecified Unspecified
unspecified Severity unspecified
: ---
: 3.1
Assigned To: ruby maint
BaseOS QE - Apps
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-08-07 05:01 EDT by Joe Orton
Modified: 2017-08-08 05:06 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
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:
always

Steps to Reproduce:
$ cat <<EOF > foo
> #!/usr/bin/scl enable rh-ruby22 -- ruby
> puts 'Hello, Brave New World.'
> EOF
$ 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
> EOF

$ 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
ruby-2.4.1-79.fc27.x86_64

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