-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make rubygem use /usr/bin/env in shebang in script #4907
Comments
JRuby should default RubyGems to using "env shebang" lines. If you install the native JRuby executable, we change that logic to use absolute path to the native binary, but that doesn't match what you're seeing here. How did you install JRuby? |
I have a python script for "bootstraping" jruby with jekyll on a Windows 7 machine because -- as I have written in #4890 -- I need to later run jekyll on build machines with no internet access. The bootstrap python script does the following steps:
I have to note that |
One more insight: I've run my bootstrap script on a linux machine and got a This is a bit assymetric. "Bootstrapping" on Windows produces batch files and shell scripts (with the latter having wrong shebangs), while "bootstrapping" on Linux produces correct shell scripts, but no batch files at all. This breaks my naive assumption that I could "bootstrap" jruby with jekyll on any platform, either Windows or Linux, and then use the produced self-contained jruby folder on any machine with an installed JRE, be it Windows or Linux. |
Ahh so this seems to be a limitation of RubyGems then? We make no modifications to RubyGems other than through defaults...perhaps there's a way to configure it to always install batch files. |
To clarify what I'm hearing:
Here's the code that generates the .bat files: def generate_windows_script(filename, bindir)
if Gem.win_platform? then
script_name = filename + ".bat"
script_path = File.join bindir, File.basename(script_name)
File.open script_path, 'w' do |file|
file.puts windows_stub_script(bindir, filename)
end
verbose script_path
end
end Seems like you want a new feature for RubyGems to force it to always generate both.
Is this correct? In any case this seems like RubyGems issues or features, so perhaps there's nothing to do on JRuby's end. |
Hi Charles, Thank you very much for your time looking into it. Your summary is correct. I'm sorry for the noise here on the jruby issue tracker. The fact that the behavior was inconsistent depending on the platform misled me into thinking that some config option has not been set correctly in jruby. But as you have already pointed out, this seems to be an issue with rubygems. Being completely new to the ruby ecosystem, it was hard for me to see where exactly the root cause might have been. So thanks again for pointing me in the right direction. Then again, it is not yet completely clear to me whether the behaviour I naively expected would be a feature request for jruby or rubygems. I was thinking of jruby as a portable alternative to a native ruby setup and therefore assumed that it just came with working scripts for Windows (batch files) and Unix-style systems (shebang). And I think my assumption was not too far-stretched as the vanilla jruby distribution contains batch files and shebang-files for jruby, gem, rake etc. I assume that asking rubygems to generate batch files on Unix-like systems and shebang-style files on Windows systems per default would be frowned upon for a native ruby installation, don't you think? So maybe the feature request for rubygems would be the following:
Once this is possible, a feature request for jruby might be:
This would result in a jruby folder with optionally addition gems that could be just copied over across different host operating systems. Things would then work as long as there is a JRE installed and the PATH variable set correctly. Does that sound reasonable to you? |
I think one possible solution would be for users to be able to generate the desired variants, |
It looks like a RubyGems flag is acceptable to the RG folks, so I'm going to close this. |
I have another issue, kind of related to #4890, which affects portability. I want to use jruby in a portable way within a build machine. In my particular case, I'm using jekyll installed by rubygems in jruby, setting the PATH variable to include
<path-to-jruby>/bin
. However, this currently fails because of the shebang used inbin/jekyll
readsI'd like to propose to use
/usr/bin/env
instead:There seems to be a configuration variable which is used by the
shebang
function within jruby. See https://github.com/rubygems/rubygems/blob/dfc9c72a91b14a5d630fc141cf30312da3bf2ba7/lib/rubygems/installer.rb#L538-L592I don't really know a thing about ruby and how things work together in detail, but in contrast to #4890 it looks to me as if this issue should be directly fixable in jruby by setting the configuration. But I might be completely wrong, of course.
The text was updated successfully, but these errors were encountered: