diff --git a/guix/gexp.scm b/guix/gexp.scm
index a2ba50d95784a29622a0e2c5a29302ee00f4a0e8..3b154d400f3cdee1ff4b59623c0382a3c555f756 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -351,6 +351,10 @@ (define* (gexp->script name exp
                       (gexp
                        (call-with-output-file (ungexp output)
                          (lambda (port)
+                           ;; Note: that makes a long shebang.  When the store
+                           ;; is /gnu/store, that fits within the 128-byte
+                           ;; limit imposed by Linux, but that may go beyond
+                           ;; when running tests.
                            (format port
                                    "#!~a/bin/guile --no-auto-compile~%!#~%"
                                    (ungexp guile))
diff --git a/tests/gexp.scm b/tests/gexp.scm
index 21606b510bb48af0b2aff98695f2317692d6edf0..60adf497ed8318358a4449774a9aee732f63eb82 100644
--- a/tests/gexp.scm
+++ b/tests/gexp.scm
@@ -211,6 +211,14 @@ (define (match-input thing)
     (return (string=? (readlink (string-append out "/foo"))
                       guile))))
 
+(define shebang
+  (string-append (derivation->output-path guile-for-build)
+                 "/bin/guile --no-auto-compile"))
+
+;; If we're going to hit the silly shebang limit (128 chars on Linux-based
+;; systems), then skip the following test.
+(test-skip (if (> (string-length shebang) 127) 1 0))
+
 (test-assertm "gexp->script"
   (mlet* %store-monad ((n ->   (random (expt 2 50)))
                        (exp -> (gexp