diff --git a/distrobox-assemble b/distrobox-assemble
index c39893e38c..bd7b36c7a6 100755
--- a/distrobox-assemble
+++ b/distrobox-assemble
@@ -18,6 +18,11 @@
# You should have received a copy of the GNU General Public License
# along with distrobox; if not, see .
+# Ensure we have our env variables correctly set
+[ -z "${USER}" ] && USER="$(id -run)"
+[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
+[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"
+
# POSIX
#
default_input_file="./distrobox.ini"
diff --git a/distrobox-create b/distrobox-create
index 2c05d1b25d..5503155e73 100755
--- a/distrobox-create
+++ b/distrobox-create
@@ -49,6 +49,11 @@ if {
exit 1
fi
+# Ensure we have our env variables correctly set
+[ -z "${USER}" ] && USER="$(id -run)"
+[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
+[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"
+
# Defaults
container_additional_packages=""
container_additional_volumes=""
diff --git a/distrobox-enter b/distrobox-enter
index b018774245..21fb7b0218 100755
--- a/distrobox-enter
+++ b/distrobox-enter
@@ -37,6 +37,11 @@
# DBX_SKIP_WORKDIR
# DBX_SUDO_PROGRAM
+# Ensure we have our env variables correctly set
+[ -z "${USER}" ] && USER="$(id -run)"
+[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
+[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"
+
app_cache_dir=${XDG_CACHE_HOME:-"${HOME}/.cache"}/distrobox
trap cleanup TERM INT HUP EXIT
diff --git a/distrobox-ephemeral b/distrobox-ephemeral
index 46a5c6de88..eefdc71617 100755
--- a/distrobox-ephemeral
+++ b/distrobox-ephemeral
@@ -39,6 +39,11 @@ if {
exit 1
fi
+# Ensure we have our env variables correctly set
+[ -z "${USER}" ] && USER="$(id -run)"
+[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
+[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"
+
trap cleanup TERM INT HUP
name=$(mktemp -u distrobox-XXXXXXXXXX)
diff --git a/distrobox-export b/distrobox-export
index 4c54817534..f09e404028 100755
--- a/distrobox-export
+++ b/distrobox-export
@@ -25,6 +25,11 @@
# DISTROBOX_ENTER_PATH
# DISTROBOX_HOST_HOME
+# Ensure we have our env variables correctly set
+[ -z "${USER}" ] && USER="$(id -run)"
+[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
+[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"
+
# Defaults
export_action=""
exported_app=""
diff --git a/distrobox-generate-entry b/distrobox-generate-entry
index 40a4ac63a5..5191829acd 100755
--- a/distrobox-generate-entry
+++ b/distrobox-generate-entry
@@ -37,6 +37,11 @@ if {
exit 1
fi
+# Ensure we have our env variables correctly set
+[ -z "${USER}" ] && USER="$(id -run)"
+[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
+[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"
+
# If the user runs this script as root in a login shell, set rootful=1.
# There's no need for them to pass the --root flag option in such cases.
[ "$(id -ru)" -eq 0 ] && rootful=1 || rootful=0
diff --git a/distrobox-host-exec b/distrobox-host-exec
index b75022b4d8..f4690f26f1 100755
--- a/distrobox-host-exec
+++ b/distrobox-host-exec
@@ -18,6 +18,11 @@
# You should have received a copy of the GNU General Public License
# along with distrobox; if not, see .
+# Ensure we have our env variables correctly set
+[ -z "${USER}" ] && USER="$(id -run)"
+[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
+[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"
+
# Defaults
host_command=""
non_interactive=0
diff --git a/distrobox-list b/distrobox-list
index 3a755eaff3..ada7371e13 100755
--- a/distrobox-list
+++ b/distrobox-list
@@ -38,6 +38,11 @@ if {
exit 1
fi
+# Ensure we have our env variables correctly set
+[ -z "${USER}" ] && USER="$(id -run)"
+[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
+[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"
+
# Defaults
no_color=0
# If the user runs this script as root in a login shell, set rootful=1.
diff --git a/distrobox-rm b/distrobox-rm
index 337884b67e..67e2187337 100755
--- a/distrobox-rm
+++ b/distrobox-rm
@@ -41,6 +41,11 @@ if {
exit 1
fi
+# Ensure we have our env variables correctly set
+[ -z "${USER}" ] && USER="$(id -run)"
+[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
+[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"
+
# Defaults
all=0
container_manager="autodetect"
diff --git a/distrobox-stop b/distrobox-stop
index b736ff8edb..63b613095a 100755
--- a/distrobox-stop
+++ b/distrobox-stop
@@ -40,6 +40,11 @@ if {
exit 1
fi
+# Ensure we have our env variables correctly set
+[ -z "${USER}" ] && USER="$(id -run)"
+[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
+[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"
+
# Defaults
all=0
container_manager="autodetect"
diff --git a/distrobox-upgrade b/distrobox-upgrade
index 0c94f34ca5..b5b8f91751 100755
--- a/distrobox-upgrade
+++ b/distrobox-upgrade
@@ -32,6 +32,11 @@ if {
exit 1
fi
+# Ensure we have our env variables correctly set
+[ -z "${USER}" ] && USER="$(id -run)"
+[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
+[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"
+
all=0
running=0
container_manager="autodetect"