heroku/heroku — pull request #1211 by berdario (2014-09-21 19:35:32+00:00)
Title: shebang breaks the executable on systems with {rbenv,rvm}-managed rubies

This is basically the same issue mentioned in [this comment](https://github.com/heroku/heroku/issues/174#issuecomment-3964500)

Using `env` in the shebang is all fine and dandy as long as you have a standalone script that can run on different ruby versions, but as soon as you add some dependencies (like in heroku's case) you cannot expect that the interpreter in the current environment has them installed. I stumbled upon this issue after installing the heroku toolbelt from its deb repositories on a normal ubuntu system with multiple rubies managed by `rbenv`. So the scripts should rely on the same ruby interpreter that has been required as a dependency by the debian package, not the one resolved by `env`

(granted, rather than merging this you might want to tweak `deb.rake` to take care of possible differences in the location of the `ruby` executable on different distros)

An example of another application that avoids `env` in its executable's shebang is `dropbox`, and indeed the dropbox script works just fine even when invoked from inside a virtualenv (which is sort of the python equivalent of rbenv, rvm)