David J.
David J.

Reputation: 32715

When/why to use --env-shebang with ruby gems?

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.)

Upvotes: 4

Views: 1974

Answers (2)

Darshan Rivka Whittle
Darshan Rivka Whittle

Reputation: 34041

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.

Upvotes: 5

m-rod
m-rod

Reputation: 41

/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.

Upvotes: 2

Related Questions