You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After installing a gem through "gem install mygem --env-shebang", after the wrapper gets overwritten by the fix-wrapper.rb hook, the shebang is overwritten as @env_shebang is not defined in RubyGemsBundlerInstaller. It should take into account the configuration passed in gem.
The text was updated successfully, but these errors were encountered:
def shebang(bin_file_name)
ruby_name = Gem::ConfigMap[:ruby_install_name] if @env_shebang
...
if not ruby_name then
"#!#{Gem.ruby}#{opts}"
elsif opts then
"#!/bin/sh\n'exec' #{ruby_name.dump} '-x' \"$0\" \"$@\"\n#{shebang}"
else
# Create a plain shebang line.
"#!#{@env_path} #{ruby_name}"
end
end
Where the @env_shebang variable comes from (also in installer.rb)
And is defined when launching the gem install/upgrade command with --env-shebang or -E flags.
Then, after installing the gems, the hooks are executed. In fix_wrapper.rb:
module Gem
post_install do |inst|
RubyGemsBundlerInstaller.bundler_generate_bin(inst)
end
end
Which calls bundler_generate_bin to rewrite the wrapper (in rubygems-bundler/rubygems_bundler_installer.rb). It uses a modified version of the shebang proc:
def self.shebang(inst, bin_file_name)
ruby_name = Gem::ConfigMap[:ruby_install_name] if @env_shebang
...
if not ruby_name then
"#!#{Gem.ruby}#{opts}"
...
end
...
end
In the above proc, as @env_shebang is never defined, the condition does not match and hence, the shebang is written as "#!#{Gem.ruby}#{opts}" (regardless of if @env_shebang was true in the rubygems portion of the execution).
I believe a possible patch would be using:
def self.shebang(inst, bin_file_name)
ruby_name = Gem::ConfigMap[:ruby_install_name] if inst.options[@env_shebang]
...
end
Using inst.options to access the passed in options but I have not verified it.
After installing a gem through "gem install mygem --env-shebang", after the wrapper gets overwritten by the fix-wrapper.rb hook, the shebang is overwritten as @env_shebang is not defined in RubyGemsBundlerInstaller. It should take into account the configuration passed in gem.
The text was updated successfully, but these errors were encountered: