--- share/spack/setup-env.sh 2021-11-15 00:06:07.160481958 +0100 +++ share/spack/setup-env.sh 2021-11-15 00:09:10.820476320 +0100 @@ -45,6 +45,10 @@ fi export _sp_initializing=true +_pkexec_env() { + /usr/bin/spack $@ +} + _spack_shell_wrapper() { # Store LD_LIBRARY_PATH variables from spack shell function @@ -75,7 +79,7 @@ [ "${_sp_flags#*h}" != "${_sp_flags}" ] || \ [ "${_sp_flags#*V}" != "${_sp_flags}" ]; then - command spack $_sp_flags "$@" + _pkexec_env $_sp_flags "$@" return fi @@ -96,7 +100,7 @@ shift fi if [ "$_sp_arg" = "-h" ] || [ "$_sp_arg" = "--help" ]; then - command spack cd -h + _pkexec_env cd -h else LOC="$(spack location $_sp_arg "$@")" if [ -d "$LOC" ] ; then @@ -115,7 +119,7 @@ fi if [ "$_sp_arg" = "-h" ] || [ "$_sp_arg" = "--help" ]; then - command spack env -h + _pkexec_env env -h else case $_sp_arg in activate) @@ -132,10 +136,10 @@ [ "${_a#* --help}" != "$_a" ]; then # No args or args contain --sh, --csh, or -h/--help: just execute. - command spack env activate "$@" + _pkexec_env env activate "$@" else # Actual call to activate: source the output. - stdout="$(SPACK_COLOR="${SPACK_COLOR:-always}" command spack $_sp_flags env activate --sh "$@")" || return + stdout="$(SPACK_COLOR="${SPACK_COLOR:-always}" _pkexec_env $_sp_flags env activate --sh "$@")" || return eval "$stdout" fi ;; @@ -151,18 +155,18 @@ [ "${_a#* --csh}" != "$_a" ]; then # Args contain --sh or --csh: just execute. - command spack env deactivate "$@" + _pkexec_env env deactivate "$@" elif [ -n "$*" ]; then # Any other arguments are an error or -h/--help: just run help. - command spack env deactivate -h + _pkexec_env env deactivate -h else # No args: source the output of the command. - stdout="$(SPACK_COLOR="${SPACK_COLOR:-always}" command spack $_sp_flags env deactivate --sh)" || return + stdout="$(SPACK_COLOR="${SPACK_COLOR:-always}" _pkexec_env $_sp_flags env deactivate --sh)" || return eval "$stdout" fi ;; *) - command spack env $_sp_arg "$@" + _pkexec_env env $_sp_arg "$@" ;; esac fi @@ -183,14 +187,14 @@ [ "${_a#* --help}" != "$_a" ]; then # Args contain --sh, --csh, or -h/--help: just execute. - command spack $_sp_flags $_sp_subcommand "$@" + _pkexec_env $_sp_flags $_sp_subcommand "$@" else - stdout="$(SPACK_COLOR="${SPACK_COLOR:-always}" command spack $_sp_flags $_sp_subcommand --sh "$@")" || return + stdout="$(SPACK_COLOR="${SPACK_COLOR:-always}" _pkexec_env $_sp_flags $_sp_subcommand --sh "$@")" || return eval "$stdout" fi ;; *) - command spack $_sp_flags $_sp_subcommand "$@" + _pkexec_env $_sp_flags $_sp_subcommand "$@" ;; esac } @@ -365,7 +369,7 @@ _spack_pathadd PATH "${_sp_module_bin}" fi; else - stdout="$(command spack --print-shell-vars sh)" || return + stdout="$(_pkexec_env --print-shell-vars sh)" || return eval "$stdout" fi;