What is your preferred Guile shebang?

What is your preferred shebang for Guile scripts? I doubt the following would work, as env cannot have arguments.

#!/usr/bin/env guile -s


  • Trisquel puts Guile in /usr/bin/guile
  • Guix System puts Guile in /run/current-system/profile/bin/guile
  • Other systems put Guile in /usr/local/bin/guile

There is no standard path for Guile, so choosing a shebang is tricky.

The most portable way to choose your executable in a POSIX shell script is with the /usr/bin/env command, and allow env to resolve the script’s interpreter executable path using the PATH environment variable. I know Nix OS ensures the /usr/bin/env path points to the correct env executable, and I think Guix does as well, although I do not use Guix OS so I can’t try it myself.

You must pass the -S flag to /usr/bin/env or else it will treat arguments to Guile as if they were part of the command name. So your shebang line should look like this:

#! /usr/bin/env -S guile --r7rs -q -s

Note that I also prefer to use R7RS compliant Scheme, and that I pass -q so that my personal Guile options are not included in my Guile scripts, as it may bind symbols I rely on which other people may not.

There are times when it would be better to not use /usr/bin/env, for example if you are distributing your script as part of a containerized app, or if your script is intended to be used only on a specific platform. In these cases it would be best to point your shebang to the executable path directly, e.g. /run/current-system/profile/bin/guile for Guix OS only scripts.