问题
Ikenna Okpala recommended this .gemrc (I modified it slightly):
--- :verbose: true :bulk_threshold: 1000 install: --no-ri --no-rdoc --env-shebang :sources: - http://gems.rubyforge.org/ :benchmark: false :backtrace: false update: --no-ri --no-rdoc --env-shebang :update_sources: true
I had not noticed the --env-shebang
before. I looked up the documentation for --env-shebang
at http://guides.rubygems.org/command-reference/:
Install/Update Options: ... -E, --[no-]env-shebang - Rewrite the shebang line on installed scripts to use /usr/bin/env
Practically speaking, why might the --env-shebang
option be important? (I've never used it.)
回答1:
If for some reason the gem's author didn't use #!/usr/bin/env ruby
you may well want to have it automatically changed.
(If you're asking why you'd want the env
shebang line at all, this explains it pretty well.)
The beginning of the rubygems-developers thread discussing the idea for this feature is here.
回答2:
/usr/bin/env is a Unix program that checks a user's path to see how a program should be run. Using /usr/bin/env allows the person using the program to be able to choose their own version of Ruby rather than the one that might happen to be installed by default on the system. Rather than hardcoding a location for Ruby, you can let the user decide where it is.
来源:https://stackoverflow.com/questions/11495893/when-why-to-use-env-shebang-with-ruby-gems