Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 911513 - ruby-fakegem.eclass: Use /usr/bin/ruby directly as shebang
Summary: ruby-fakegem.eclass: Use /usr/bin/ruby directly as shebang
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Ruby Team
Depends on:
Reported: 2023-07-31 02:06 UTC by konsolebox
Modified: 2023-08-02 12:40 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---

Patch (ruby-fakegem-usr-bin-ruby.patch,917 bytes, patch)
2023-07-31 02:06 UTC, konsolebox
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description konsolebox 2023-07-31 02:06:54 UTC
Created attachment 866697 [details, diff]

Having `/usr/bin/env ruby` as shebang allows the system-installed exe to be executed by user-installed Ruby which will fail unless the user-installed Ruby and its gems are compatible with the exe.  The exe is system-installed and it shouldn't be affected by user setups.  Shadowing executables is a problem the user Ruby's installer should care about; not the system.  The exe should always run properly and run using its correct system-installed dependencies when its stub in /usr/bin is called no matter what.  If there maybe stubs that have to be generic, it's the ones installed by the user Ruby's installer.
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-07-31 02:12:38 UTC
I don't think we want to lose the ability to override it by PATH.
Comment 2 konsolebox 2023-07-31 02:15:46 UTC
> I don't think we want to lose the ability to override it by PATH.

That's inconsistent because you won't be able to anyway if there are at least two implementations installed.
Comment 3 konsolebox 2023-07-31 02:28:33 UTC
Sorry it's the other way around. If there's only one implementation, shebang should be like /usr/bin/ruby31, and in that case PATH isn't useful.

Also it still doesn't make sense. Why would you want a system-installed stub to be flexible? It should always just call the ones it was installed for. Even in prefix mode it doesn't make sense. You wouldn't need to use the previous non-prefixed gems.
Comment 4 konsolebox 2023-08-02 12:40:19 UTC
I just created "rubyexec", a wrapper written in C:

This makes it even more certain a bin application only runs with its target Ruby implementations.

Example shebang usage in stub:

#!/usr/bin/rubyexec ruby31,ruby30

Wouldn't matter how many implementations are around.  It wouldn't allow the application to execute if /usr/bin/ruby points to an implementation the application doesn't support, and instead pick the first available implementation from the comma-separated list.