diff --git a/build/bin/sage-spkg b/build/bin/sage-spkg
index 83e61a7e0d..942ba206c7 100755
--- a/build/bin/sage-spkg
+++ b/build/bin/sage-spkg
@@ -648,8 +648,12 @@ if ! sage-apply-patches; then
     error_msg "Error applying patches"
     exit 1
 fi
+
+@bash@/bin/bash @patchSageShebangs@ .
+
 cd ..
 
+
 ##################################################################
 # The package has been extracted, prepare for installation
 ##################################################################
@@ -671,7 +675,7 @@ write_script_wrapper() {
     local tmpscript="$(dirname "$script")/.tmp-${script##*/}"
 
     cat > "$tmpscript" <<__EOF__
-#!/usr/bin/env bash
+#! @bash@/bin/bash
 
 export SAGE_ROOT="$SAGE_ROOT"
 export SAGE_SRC="$SAGE_SRC"
@@ -833,6 +837,9 @@ if [ "$UNAME" = "CYGWIN" ]; then
     sage-rebase.sh "$SAGE_LOCAL" 2>/dev/null
 fi
 
+@bash@/bin/bash @patchSageShebangs@ .
+@bash@/bin/bash @patchSageShebangs@ "$out/bin"
+
 echo "Successfully installed $PKG_NAME"
 
 if [ "$SAGE_CHECK" = "yes" ]; then