From Fedora Project Wiki

No edit summary
Line 5: Line 5:
This strategy works well when the applications we ship use a shebang line that directly calls the interpreter like this: <code>#! /usr/bin/python</code> as there's no ambiguitiy in which version of python the packages will invoke.  When we use <code>#! /usr/bin/env python</code> in the shebang line, there is ambiguity.  Depending on the user's PATH variable, they may end up invoking the python that we ship or the copy that we've installed.  This can lead to breakage where the application is not compatible with both versions of the interpreter.
This strategy works well when the applications we ship use a shebang line that directly calls the interpreter like this: <code>#! /usr/bin/python</code> as there's no ambiguitiy in which version of python the packages will invoke.  When we use <code>#! /usr/bin/env python</code> in the shebang line, there is ambiguity.  Depending on the user's PATH variable, they may end up invoking the python that we ship or the copy that we've installed.  This can lead to breakage where the application is not compatible with both versions of the interpreter.


Also, RPM does dependency addtions based on script interpreter lines. If a script has <code>#! /usr/bin/env python</code>, the dependency added to the resulting rpm is on /usr/bin/env, <em>not</em> on the actual python interpreter. This may lead to incorrect dependencies, and broken scripts.
Also, RPM does dependency additions based on script interpreter lines. If a script has <code>#! /usr/bin/env python</code>, the dependency added to the resulting rpm is on /usr/bin/env, <em>not</em> on the actual python interpreter. This may lead to incorrect dependencies, and broken scripts.


For these reasons, Fedora packages must not use <code>/usr/bin/env</code> to invoke the interpreter in the shebang line.
For these reasons, Fedora packages must not use <code>/usr/bin/env</code> to invoke the interpreter in the shebang line.


[[Category:Packaging guidelines drafts]]
[[Category:Packaging guidelines drafts]]

Revision as of 16:28, 17 July 2009

Do not use #! /usr/bin/env INTERPRETER

Fedora ships with only a single version of most interpreters (python, perl, php, etc). The application packages we build all target this version. However, the end user may install other versions of the interpreter to satisfy their own requirements. For instance, Fedora 11 ships with /usr/bin/python which is python-2.6. The user may need to run Zope on their machine which necessitates python-2.4. They can install this in /usr/local/bin and point their zope instance at it.

This strategy works well when the applications we ship use a shebang line that directly calls the interpreter like this: #! /usr/bin/python as there's no ambiguitiy in which version of python the packages will invoke. When we use #! /usr/bin/env python in the shebang line, there is ambiguity. Depending on the user's PATH variable, they may end up invoking the python that we ship or the copy that we've installed. This can lead to breakage where the application is not compatible with both versions of the interpreter.

Also, RPM does dependency additions based on script interpreter lines. If a script has #! /usr/bin/env python, the dependency added to the resulting rpm is on /usr/bin/env, not on the actual python interpreter. This may lead to incorrect dependencies, and broken scripts.

For these reasons, Fedora packages must not use /usr/bin/env to invoke the interpreter in the shebang line.