Bug 1478833 - Ruby shebang interpreter misinterpretation
Summary: Ruby shebang interpreter misinterpretation
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Software Collections
Classification: Red Hat
Component: ruby
Version: rh-ruby24
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: 3.4
Assignee: ruby maint
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-08-07 09:01 UTC by Joe Orton
Modified: 2020-03-05 13:01 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-03-05 13:01:31 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Ruby 13786 0 None None None 2017-08-07 17:18:15 UTC

Description Joe Orton 2017-08-07 09:01:59 UTC
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 16:32:55 UTC
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

Comment 6 Pavel Valena 2018-11-19 19:17:36 UTC
This is still an issue in both Ruby 2.3.8 and 2.4.5, but it's fixed in Ruby 2.5.

Comment 8 Joe Orton 2020-03-05 13:01:31 UTC
Confirmed this works with rh-ruby26 & rh-ruby27 at least - thanks!


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