[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: RFH: Skripts in /usr/bin relying on version specific extensions and shebang line in these scripts



On Mon, Nov 01, 2021 at 01:14:49PM +0100, Daniel Leidert wrote:
> Hi there,
> 
> while working on ruby-byebug I came across a question I cannot answer myself.
> So in case of this package there is a script with a shebang line like
> 
> #!/usr/bin/env ruby
> 
> This line at the moment will lead to the script being executed with Ruby 2.7.
> Now this script is also put into
> 
> usr/lib/x86_64-linux-gnu/rubygems-integration/2.7.0/gems/byebug-11.1.3/exe/byebug
> usr/lib/x86_64-linux-gnu/rubygems-integration/3.0.0/gems/byebug-11.1.3/exe/byebug
> 
> Now in the latter we would need to fix the shebang line to actually run it with
> Ruby 3. I do wonder:
> 
> a) Should gem2deb handle and fix shebang lines in those directories (and or in
> /usr/bin)?

Shebangs in /usr/bin are already handled by gem2deb.

Those in the gem directory are not supposed to be executed directly, but
they are loaded by the scripts in /usr/bin:

───────┬──────────────────────────────────────────────────────────────
       │ File: /usr/bin/byebug
───────┼──────────────────────────────────────────────────────────────
       │ [...]
  22   │ if Gem.respond_to?(:activate_bin_path)
  23   │ load Gem.activate_bin_path('byebug', 'byebug', version)
  24   │ else
  25   │ gem "byebug", version
  26   │ load Gem.bin_path("byebug", "byebug", version)
  27   │ end
───────┴──────────────────────────────────────────────────────────────

Did you see them being executed directly? Where?

> b) Should those directories be removed by gem2deb?

No because that will break the script in /usr/bin

> c) How to handle such scripts using ruby version specific extensions? Should
> they point to Ruby 2.7 until we finally switch over? Can they even work within
> a ruby 3 project at the moment?

That's already the case for the scripts in /usr/bin. AFAICT we don't
have to worry about those internal scripts in the gem directory as they
are not supposed to be run directly.

If we were going to rewrite shebangs in them, it would be to hardcode
the ruby version are supposed to be run with, i.e.

usr/lib/x86_64-linux-gnu/rubygems-integration/2.7.0/gems/byebug-11.1.3/exe/byebug
would have its shebang rewritten to /usr/bin/ruby2.7 and
usr/lib/x86_64-linux-gnu/rubygems-integration/3.0.0/gems/byebug-11.1.3/exe/byebug
would have its shebang rewritten to /usr/bin/ruby3.0

But I'm still not sure if that's needed.

Attachment: signature.asc
Description: PGP signature


Reply to: