Nix-shell exits if shellHook set -e is added

I mostly want to know why this is the behavior and if it is intended.
Steps to reproduce:
shell.nix
{ pkgs ? import { } }:

pkgs.mkShell {
buildInputs = [
pkgs.python311
pkgs.uv
];

shellHook = ‘’
set -uo pipefail
echo “Running shellHook…”

if [ ! -e ./pyproject.toml ]; then
   uv init --app --no-readme --no-package
fi

if [ ! -e ./.venv/ ]; then
  uv venv --python 3 || true
fi

echo "After uv venv python..."

uv pip install -e . >/dev/null 2>&1 || uv pip install -e .

echo "After install ..."

‘’;
}
if set has the -e flag, the nix-shell exits: from set -uo … to set -euo …

And what is the output during that fail?

Have you considered also adding -x for additional output?

1 Like

First, thank you for telling me bout -x( didn’t know there is such a thing, time to brush up on my bash knowledge i guess).
output of uv run ./ then tab press:

+ _comp_load -D -- uv
+ local flag_fallback_default= 'IFS= 	
'
+ local OPTIND=1 OPTARG= OPTERR=0 opt
+ getopts :D opt -D -- uv
+ case $opt in
+ flag_fallback_default=set
+ getopts :D opt -D -- uv
+ shift 2
+ local cmd=uv cmdname=uv dir compfile
+ local -a paths
+ [[ -n uv ]]
+ local backslash=
+ [[ uv == \\* ]]
+ local REPLY pathcmd origcmd=uv
++ type -P -- uv
+ pathcmd=/nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin/uv
+ _comp_abspath /nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin/uv
+ REPLY=/nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin/uv
+ case $REPLY in
+ [[ /nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin/uv == */./* ]]
+ REPLY=/nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin/uv
+ cmd=/nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin/uv
+ dirs=()
+ local -a dirs
+ [[ -n '' ]]
+ dirs=("${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion/completions")
+ [[ /nix/store/knkgz12zyg83w9g61xys6qjxwxgmymh5-bash-completion-2.14.0/share/bash-completion/bash_completion == */* ]]
+ dirs+=("${BASH_SOURCE%/*}/completions")
+ paths=()
+ [[ /nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin/uv == /* ]]
+ paths+=("${cmd%/*}")
+ _comp_realcommand /nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin/uv
+ REPLY=
+ local file
++ type -P -- /nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin/uv
+ file=/nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin/uv
+ type -p realpath
++ realpath /nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin/uv
+ REPLY=/nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin/uv
+ paths+=("${REPLY%/*}")
+ _comp_split -aF : paths /nix/store/x9d49vaqlrkw97p9ichdwrnbh013kq7z-bash-interactive-5.2p37/bin:/nix/store/wnl9qpnhayry14lhcbdafhadsjwsdr6p-patchelf-0.15.0/bin:/nix/store/888bkaqdpfpx72dd8bdc69qsqlgbhcvf-gcc-wrapper-13.3.0/bin:/nix/store/62qjb50708fdhb4f2y7zxyqr1afir4fk-gcc-13.3.0/bin:/nix/store/29mb4q8b5306f4gk2wh38h0c1akb0n97-glibc-2.40-36-bin/bin:/nix/store/6wgd8c9vq93mqxzc7jhkl86mv6qbc360-coreutils-9.5/bin:/nix/store/qlzvmgr8w9prdlyys7irqf86p7bndf5b-binutils-wrapper-2.43.1/bin:/nix/store/vk4mlknqk9yjbqa68a7rvpfxfdw3rad7-binutils-2.43.1/bin:/nix/store/3alx4nrhy7ss32i6fmfgj0hp96pfjvx6-python3-3.11.11/bin:/nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin:/nix/store/kjgslpdqchx1sm7a5h9xibi5rrqcqfnl-python3-3.12.8/bin:/nix/store/6wgd8c9vq93mqxzc7jhkl86mv6qbc360-coreutils-9.5/bin:/nix/store/r99d2m4swgmrv9jvm4l9di40hvanq1aq-findutils-4.10.0/bin:/nix/store/3sln66ij8pg114apkd8p6nr04y37q5z2-diffutils-3.10/bin:/nix/store/yq39xdwm4z0fhx7dsm8mlpgvcz3vbfg3-gnused-4.9/bin:/nix/store/vniy1y5n8g28c55y7788npwc4h09fh7c-gnugrep-3.11/bin:/nix/store/scgfwh3z1s3l2vhvyjsgfgx5ql552sls-gawk-5.3.1/bin:/nix/store/0wqn2k3v5xzrc9rwinijdyr2ywwl82x4-gnutar-1.35/bin:/nix/store/5y240z436gf3rwmkwbhn1a17pqw509w4-gzip-1.13/bin:/nix/store/1yyryxp7mh7zsciapi8f1n0mnxkigmf8-bzip2-1.0.8-bin/bin:/nix/store/hbzw8k8ygv6bfzvsvnd4gb8qmm8xjbvn-gnumake-4.4.1/bin:/nix/store/gwgqdl0242ymlikq9s9s62gkp5cvyal3-bash-5.2p37/bin:/nix/store/rfrjws98w6scfx7m63grb0m6sg925ahd-patch-2.7.6/bin:/nix/store/4i4mjaf7z6gddspar487grxk5k1j4dcd-xz-5.6.3-bin/bin:/nix/store/9wbpsj6ksd16x1qdqs29xli1dpz3fnl0-file-5.45/bin:/nix/store/95im22i65wnsgnj7lw1vsl5iy62lypv9-kitty-0.37.0/bin:/nix/store/9dnll67932lkqjh31nw6k9kim2prah85-imagemagick-7.1.1-40/bin:/nix/store/69v6c64pn1ay26207b0cmzi40qpr9q0w-ncurses-6.4.20221231-dev/bin:/run/wrappers/bin:/home/cake/.nix-profile/bin:/nix/profile/bin:/home/cake/.local/state/nix/profile/bin:/etc/profiles/per-user/cake/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin
+ local _append= 'IFS= 	
'
+ local OPTIND=1 OPTARG= OPTERR=0 _opt
+ getopts :alF: _opt -aF : paths /nix/store/x9d49vaqlrkw97p9ichdwrnbh013kq7z-bash-interactive-5.2p37/bin:/nix/store/wnl9qpnhayry14lhcbdafhadsjwsdr6p-patchelf-0.15.0/bin:/nix/store/888bkaqdpfpx72dd8bdc69qsqlgbhcvf-gcc-wrapper-13.3.0/bin:/nix/store/62qjb50708fdhb4f2y7zxyqr1afir4fk-gcc-13.3.0/bin:/nix/store/29mb4q8b5306f4gk2wh38h0c1akb0n97-glibc-2.40-36-bin/bin:/nix/store/6wgd8c9vq93mqxzc7jhkl86mv6qbc360-coreutils-9.5/bin:/nix/store/qlzvmgr8w9prdlyys7irqf86p7bndf5b-binutils-wrapper-2.43.1/bin:/nix/store/vk4mlknqk9yjbqa68a7rvpfxfdw3rad7-binutils-2.43.1/bin:/nix/store/3alx4nrhy7ss32i6fmfgj0hp96pfjvx6-python3-3.11.11/bin:/nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin:/nix/store/kjgslpdqchx1sm7a5h9xibi5rrqcqfnl-python3-3.12.8/bin:/nix/store/6wgd8c9vq93mqxzc7jhkl86mv6qbc360-coreutils-9.5/bin:/nix/store/r99d2m4swgmrv9jvm4l9di40hvanq1aq-findutils-4.10.0/bin:/nix/store/3sln66ij8pg114apkd8p6nr04y37q5z2-diffutils-3.10/bin:/nix/store/yq39xdwm4z0fhx7dsm8mlpgvcz3vbfg3-gnused-4.9/bin:/nix/store/vniy1y5n8g28c55y7788npwc4h09fh7c-gnugrep-3.11/bin:/nix/store/scgfwh3z1s3l2vhvyjsgfgx5ql552sls-gawk-5.3.1/bin:/nix/store/0wqn2k3v5xzrc9rwinijdyr2ywwl82x4-gnutar-1.35/bin:/nix/store/5y240z436gf3rwmkwbhn1a17pqw509w4-gzip-1.13/bin:/nix/store/1yyryxp7mh7zsciapi8f1n0mnxkigmf8-bzip2-1.0.8-bin/bin:/nix/store/hbzw8k8ygv6bfzvsvnd4gb8qmm8xjbvn-gnumake-4.4.1/bin:/nix/store/gwgqdl0242ymlikq9s9s62gkp5cvyal3-bash-5.2p37/bin:/nix/store/rfrjws98w6scfx7m63grb0m6sg925ahd-patch-2.7.6/bin:/nix/store/4i4mjaf7z6gddspar487grxk5k1j4dcd-xz-5.6.3-bin/bin:/nix/store/9wbpsj6ksd16x1qdqs29xli1dpz3fnl0-file-5.45/bin:/nix/store/95im22i65wnsgnj7lw1vsl5iy62lypv9-kitty-0.37.0/bin:/nix/store/9dnll67932lkqjh31nw6k9kim2prah85-imagemagick-7.1.1-40/bin:/nix/store/69v6c64pn1ay26207b0cmzi40qpr9q0w-ncurses-6.4.20221231-dev/bin:/run/wrappers/bin:/home/cake/.nix-profile/bin:/nix/profile/bin:/home/cake/.local/state/nix/profile/bin:/etc/profiles/per-user/cake/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin
+ case $_opt in
+ _append=set
+ getopts :alF: _opt -aF : paths /nix/store/x9d49vaqlrkw97p9ichdwrnbh013kq7z-bash-interactive-5.2p37/bin:/nix/store/wnl9qpnhayry14lhcbdafhadsjwsdr6p-patchelf-0.15.0/bin:/nix/store/888bkaqdpfpx72dd8bdc69qsqlgbhcvf-gcc-wrapper-13.3.0/bin:/nix/store/62qjb50708fdhb4f2y7zxyqr1afir4fk-gcc-13.3.0/bin:/nix/store/29mb4q8b5306f4gk2wh38h0c1akb0n97-glibc-2.40-36-bin/bin:/nix/store/6wgd8c9vq93mqxzc7jhkl86mv6qbc360-coreutils-9.5/bin:/nix/store/qlzvmgr8w9prdlyys7irqf86p7bndf5b-binutils-wrapper-2.43.1/bin:/nix/store/vk4mlknqk9yjbqa68a7rvpfxfdw3rad7-binutils-2.43.1/bin:/nix/store/3alx4nrhy7ss32i6fmfgj0hp96pfjvx6-python3-3.11.11/bin:/nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin:/nix/store/kjgslpdqchx1sm7a5h9xibi5rrqcqfnl-python3-3.12.8/bin:/nix/store/6wgd8c9vq93mqxzc7jhkl86mv6qbc360-coreutils-9.5/bin:/nix/store/r99d2m4swgmrv9jvm4l9di40hvanq1aq-findutils-4.10.0/bin:/nix/store/3sln66ij8pg114apkd8p6nr04y37q5z2-diffutils-3.10/bin:/nix/store/yq39xdwm4z0fhx7dsm8mlpgvcz3vbfg3-gnused-4.9/bin:/nix/store/vniy1y5n8g28c55y7788npwc4h09fh7c-gnugrep-3.11/bin:/nix/store/scgfwh3z1s3l2vhvyjsgfgx5ql552sls-gawk-5.3.1/bin:/nix/store/0wqn2k3v5xzrc9rwinijdyr2ywwl82x4-gnutar-1.35/bin:/nix/store/5y240z436gf3rwmkwbhn1a17pqw509w4-gzip-1.13/bin:/nix/store/1yyryxp7mh7zsciapi8f1n0mnxkigmf8-bzip2-1.0.8-bin/bin:/nix/store/hbzw8k8ygv6bfzvsvnd4gb8qmm8xjbvn-gnumake-4.4.1/bin:/nix/store/gwgqdl0242ymlikq9s9s62gkp5cvyal3-bash-5.2p37/bin:/nix/store/rfrjws98w6scfx7m63grb0m6sg925ahd-patch-2.7.6/bin:/nix/store/4i4mjaf7z6gddspar487grxk5k1j4dcd-xz-5.6.3-bin/bin:/nix/store/9wbpsj6ksd16x1qdqs29xli1dpz3fnl0-file-5.45/bin:/nix/store/95im22i65wnsgnj7lw1vsl5iy62lypv9-kitty-0.37.0/bin:/nix/store/9dnll67932lkqjh31nw6k9kim2prah85-imagemagick-7.1.1-40/bin:/nix/store/69v6c64pn1ay26207b0cmzi40qpr9q0w-ncurses-6.4.20221231-dev/bin:/run/wrappers/bin:/home/cake/.nix-profile/bin:/nix/profile/bin:/home/cake/.local/state/nix/profile/bin:/etc/profiles/per-user/cake/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin
+ case $_opt in
+ IFS=:
+ getopts :alF: _opt -aF : paths /nix/store/x9d49vaqlrkw97p9ichdwrnbh013kq7z-bash-interactive-5.2p37/bin:/nix/store/wnl9qpnhayry14lhcbdafhadsjwsdr6p-patchelf-0.15.0/bin:/nix/store/888bkaqdpfpx72dd8bdc69qsqlgbhcvf-gcc-wrapper-13.3.0/bin:/nix/store/62qjb50708fdhb4f2y7zxyqr1afir4fk-gcc-13.3.0/bin:/nix/store/29mb4q8b5306f4gk2wh38h0c1akb0n97-glibc-2.40-36-bin/bin:/nix/store/6wgd8c9vq93mqxzc7jhkl86mv6qbc360-coreutils-9.5/bin:/nix/store/qlzvmgr8w9prdlyys7irqf86p7bndf5b-binutils-wrapper-2.43.1/bin:/nix/store/vk4mlknqk9yjbqa68a7rvpfxfdw3rad7-binutils-2.43.1/bin:/nix/store/3alx4nrhy7ss32i6fmfgj0hp96pfjvx6-python3-3.11.11/bin:/nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin:/nix/store/kjgslpdqchx1sm7a5h9xibi5rrqcqfnl-python3-3.12.8/bin:/nix/store/6wgd8c9vq93mqxzc7jhkl86mv6qbc360-coreutils-9.5/bin:/nix/store/r99d2m4swgmrv9jvm4l9di40hvanq1aq-findutils-4.10.0/bin:/nix/store/3sln66ij8pg114apkd8p6nr04y37q5z2-diffutils-3.10/bin:/nix/store/yq39xdwm4z0fhx7dsm8mlpgvcz3vbfg3-gnused-4.9/bin:/nix/store/vniy1y5n8g28c55y7788npwc4h09fh7c-gnugrep-3.11/bin:/nix/store/scgfwh3z1s3l2vhvyjsgfgx5ql552sls-gawk-5.3.1/bin:/nix/store/0wqn2k3v5xzrc9rwinijdyr2ywwl82x4-gnutar-1.35/bin:/nix/store/5y240z436gf3rwmkwbhn1a17pqw509w4-gzip-1.13/bin:/nix/store/1yyryxp7mh7zsciapi8f1n0mnxkigmf8-bzip2-1.0.8-bin/bin:/nix/store/hbzw8k8ygv6bfzvsvnd4gb8qmm8xjbvn-gnumake-4.4.1/bin:/nix/store/gwgqdl0242ymlikq9s9s62gkp5cvyal3-bash-5.2p37/bin:/nix/store/rfrjws98w6scfx7m63grb0m6sg925ahd-patch-2.7.6/bin:/nix/store/4i4mjaf7z6gddspar487grxk5k1j4dcd-xz-5.6.3-bin/bin:/nix/store/9wbpsj6ksd16x1qdqs29xli1dpz3fnl0-file-5.45/bin:/nix/store/95im22i65wnsgnj7lw1vsl5iy62lypv9-kitty-0.37.0/bin:/nix/store/9dnll67932lkqjh31nw6k9kim2prah85-imagemagick-7.1.1-40/bin:/nix/store/69v6c64pn1ay26207b0cmzi40qpr9q0w-ncurses-6.4.20221231-dev/bin:/run/wrappers/bin:/home/cake/.nix-profile/bin:/nix/profile/bin:/home/cake/.local/state/nix/profile/bin:/etc/profiles/per-user/cake/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin
+ shift 2
+ (( 2 != 2 ))
+ [[ paths == @(*[^_a-zA-Z0-9]*|[0-9]*||_*|IFS|OPTIND|OPTARG|OPTERR) ]]
+ local _original_opts=braceexpand:emacs:errexit:histexpand:history:interactive-comments:monitor:nounset:pipefail:xtrace
+ set -o noglob
+ local _old_size _new_size
+ [[ -n set ]]
+ eval 'paths+=()'
++ paths+=()
+ eval '_old_size=${#paths[@]}'
++ _old_size=2
+ eval 'paths+=($2)'
++ paths+=($2)
+ eval '_new_size=${#paths[@]}'
++ _new_size=37
+ [[ :braceexpand:emacs:errexit:histexpand:history:interactive-comments:monitor:nounset:pipefail:xtrace: == *:noglob:* ]]
+ set +o noglob
+ (( _new_size > _old_size ))
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/x9d49vaqlrkw97p9ichdwrnbh013kq7z-bash-interactive-5.2p37/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/wnl9qpnhayry14lhcbdafhadsjwsdr6p-patchelf-0.15.0/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/888bkaqdpfpx72dd8bdc69qsqlgbhcvf-gcc-wrapper-13.3.0/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/62qjb50708fdhb4f2y7zxyqr1afir4fk-gcc-13.3.0/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/29mb4q8b5306f4gk2wh38h0c1akb0n97-glibc-2.40-36-bin/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/6wgd8c9vq93mqxzc7jhkl86mv6qbc360-coreutils-9.5/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/qlzvmgr8w9prdlyys7irqf86p7bndf5b-binutils-wrapper-2.43.1/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/vk4mlknqk9yjbqa68a7rvpfxfdw3rad7-binutils-2.43.1/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/3alx4nrhy7ss32i6fmfgj0hp96pfjvx6-python3-3.11.11/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/kjgslpdqchx1sm7a5h9xibi5rrqcqfnl-python3-3.12.8/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/6wgd8c9vq93mqxzc7jhkl86mv6qbc360-coreutils-9.5/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/r99d2m4swgmrv9jvm4l9di40hvanq1aq-findutils-4.10.0/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/3sln66ij8pg114apkd8p6nr04y37q5z2-diffutils-3.10/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/yq39xdwm4z0fhx7dsm8mlpgvcz3vbfg3-gnused-4.9/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/vniy1y5n8g28c55y7788npwc4h09fh7c-gnugrep-3.11/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/scgfwh3z1s3l2vhvyjsgfgx5ql552sls-gawk-5.3.1/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/0wqn2k3v5xzrc9rwinijdyr2ywwl82x4-gnutar-1.35/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/5y240z436gf3rwmkwbhn1a17pqw509w4-gzip-1.13/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/1yyryxp7mh7zsciapi8f1n0mnxkigmf8-bzip2-1.0.8-bin/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/hbzw8k8ygv6bfzvsvnd4gb8qmm8xjbvn-gnumake-4.4.1/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/gwgqdl0242ymlikq9s9s62gkp5cvyal3-bash-5.2p37/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/rfrjws98w6scfx7m63grb0m6sg925ahd-patch-2.7.6/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/4i4mjaf7z6gddspar487grxk5k1j4dcd-xz-5.6.3-bin/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/9wbpsj6ksd16x1qdqs29xli1dpz3fnl0-file-5.45/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/95im22i65wnsgnj7lw1vsl5iy62lypv9-kitty-0.37.0/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/9dnll67932lkqjh31nw6k9kim2prah85-imagemagick-7.1.1-40/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/store/69v6c64pn1ay26207b0cmzi40qpr9q0w-ncurses-6.4.20221231-dev/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /run/wrappers/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /home/cake/.nix-profile/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/profile/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /home/cake/.local/state/nix/profile/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /etc/profiles/per-user/cake/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /nix/var/nix/profiles/default/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ for dir in "${paths[@]%/}"
+ [[ /run/current-system/sw/bin == ?*/@(bin|sbin) ]]
+ dirs+=("${dir%/*}/share/bash-completion/completions")
+ _comp_split -F : paths /nix/store/wnl9qpnhayry14lhcbdafhadsjwsdr6p-patchelf-0.15.0/share:/nix/store/c632nvkzjw5bv0q2bkihm5yyl0vp50dm-desktops/share:/home/cake/.nix-profile/share:/nix/profile/share:/home/cake/.local/state/nix/profile/share:/etc/profiles/per-user/cake/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share
+ local _append= 'IFS= 	
'
+ local OPTIND=1 OPTARG= OPTERR=0 _opt
+ getopts :alF: _opt -F : paths /nix/store/wnl9qpnhayry14lhcbdafhadsjwsdr6p-patchelf-0.15.0/share:/nix/store/c632nvkzjw5bv0q2bkihm5yyl0vp50dm-desktops/share:/home/cake/.nix-profile/share:/nix/profile/share:/home/cake/.local/state/nix/profile/share:/etc/profiles/per-user/cake/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share
+ case $_opt in
+ IFS=:
+ getopts :alF: _opt -F : paths /nix/store/wnl9qpnhayry14lhcbdafhadsjwsdr6p-patchelf-0.15.0/share:/nix/store/c632nvkzjw5bv0q2bkihm5yyl0vp50dm-desktops/share:/home/cake/.nix-profile/share:/nix/profile/share:/home/cake/.local/state/nix/profile/share:/etc/profiles/per-user/cake/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share
+ shift 2
+ (( 2 != 2 ))
+ [[ paths == @(*[^_a-zA-Z0-9]*|[0-9]*||_*|IFS|OPTIND|OPTARG|OPTERR) ]]
+ local _original_opts=braceexpand:emacs:errexit:histexpand:history:interactive-comments:monitor:nounset:pipefail:xtrace
+ set -o noglob
+ local _old_size _new_size
+ [[ -n '' ]]
+ _old_size=0
+ eval 'paths=($2)'
++ paths=($2)
+ eval '_new_size=${#paths[@]}'
++ _new_size=8
+ [[ :braceexpand:emacs:errexit:histexpand:history:interactive-comments:monitor:nounset:pipefail:xtrace: == *:noglob:* ]]
+ set +o noglob
+ (( _new_size > _old_size ))
+ dirs+=("${paths[@]/%//bash-completion/completions}")
+ local 'IFS= 	
'
+ shift
+ local i prefix compspec
+ for prefix in "" _
+ for i in ${!dirs[*]}
+ dir=/home/cake/.local/share/bash-completion/completions
+ [[ ! -d /home/cake/.local/share/bash-completion/completions ]]
+ unset -v 'dirs[i]'
+ continue
+ for i in ${!dirs[*]}
+ dir=/nix/store/knkgz12zyg83w9g61xys6qjxwxgmymh5-bash-completion-2.14.0/share/bash-completion/completions
+ [[ ! -d /nix/store/knkgz12zyg83w9g61xys6qjxwxgmymh5-bash-completion-2.14.0/share/bash-completion/completions ]]
+ for compfile in "$prefix$cmdname" "$prefix$cmdname.bash"
+ compfile=/nix/store/knkgz12zyg83w9g61xys6qjxwxgmymh5-bash-completion-2.14.0/share/bash-completion/completions/uv
+ [[ -d /nix/store/knkgz12zyg83w9g61xys6qjxwxgmymh5-bash-completion-2.14.0/share/bash-completion/completions/uv ]]
+ [[ -e /nix/store/knkgz12zyg83w9g61xys6qjxwxgmymh5-bash-completion-2.14.0/share/bash-completion/completions/uv ]]
+ for compfile in "$prefix$cmdname" "$prefix$cmdname.bash"
+ compfile=/nix/store/knkgz12zyg83w9g61xys6qjxwxgmymh5-bash-completion-2.14.0/share/bash-completion/completions/uv.bash
+ [[ -d /nix/store/knkgz12zyg83w9g61xys6qjxwxgmymh5-bash-completion-2.14.0/share/bash-completion/completions/uv.bash ]]
+ [[ -e /nix/store/knkgz12zyg83w9g61xys6qjxwxgmymh5-bash-completion-2.14.0/share/bash-completion/completions/uv.bash ]]
+ for i in ${!dirs[*]}
+ dir=/nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/share/bash-completion/completions
+ [[ ! -d /nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/share/bash-completion/completions ]]
+ for compfile in "$prefix$cmdname" "$prefix$cmdname.bash"
+ compfile=/nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/share/bash-completion/completions/uv
+ [[ -d /nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/share/bash-completion/completions/uv ]]
+ [[ -e /nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/share/bash-completion/completions/uv ]]
+ for compfile in "$prefix$cmdname" "$prefix$cmdname.bash"
+ compfile=/nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/share/bash-completion/completions/uv.bash
+ [[ -d /nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/share/bash-completion/completions/uv.bash ]]
+ [[ -e /nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/share/bash-completion/completions/uv.bash ]]
+ . /nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/share/bash-completion/completions/uv.bash /nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin/uv
++ [[ 5 -eq 4 ]]
++ [[ 5 -gt 4 ]]
++ complete -F _uv -o nosort -o bashdefault -o default uv
++ complete -p -- /nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin/uv
+ compspec=
+ [[ uv != \/\n\i\x\/\s\t\o\r\e\/\0\f\k\7\g\j\j\l\i\1\l\y\6\g\y\q\w\a\z\i\j\7\b\b\d\7\z\n\0\q\5\i\-\u\v\-\0\.\4\.\3\0\/\b\i\n\/\u\v ]]
++ complete -p -- uv
+ compspec='complete -o bashdefault -o default -o nosort -F _uv uv'
+ [[ /nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin/uv == /* ]]
+ eval 'complete -o bashdefault -o default -o nosort -F _uv uv "$cmd"'
++ complete -o bashdefault -o default -o nosort -F _uv uv /nix/store/0fk7gjjli1ly6gyqwazij7bbd7zn0q5i-uv-0.4.30/bin/uv
+ return 0
+ return 124
+ local i cur prev opts cmd
+ COMPREPLY=()
+ cur=./
+ prev=run
+ cmd=
+ opts=
+ for i in ${COMP_WORDS[@]}
+ case "${cmd},${i}" in
+ cmd=uv
+ for i in ${COMP_WORDS[@]}
+ case "${cmd},${i}" in
+ cmd=uv__run
+ for i in ${COMP_WORDS[@]}
+ case "${cmd},${i}" in
+ case "${cmd}" in
+ opts='-m -s -i -f -U -P -C -p -n -q -v -h -V --extra --all-extras --no-all-extras --dev --no-dev --group --no-group --only-group --module --only-dev --no-editable --env-file --no-env-file --with --with-editable --with-requirements --isolated --no-sync --locked --frozen --script --index --default-index --index-url --extra-index-url --find-links --no-index --upgrade --no-upgrade --upgrade-package --reinstall --no-reinstall --reinstall-package --index-strategy --keyring-provider --allow-insecure-host --resolution --prerelease --pre --config-setting --no-build-isolation --no-build-isolation-package --build-isolation --exclude-newer --link-mode --compile-bytecode --no-compile-bytecode --no-sources --no-build --build --no-build-package --no-binary --binary --no-binary-package --refresh --no-refresh --refresh-package --all-packages --package --no-project --python --show-resolution --no-cache --cache-dir --python-preference --allow-python-downloads --no-python-downloads --python-fetch --quiet --verbose --no-color --color --native-tls --no-native-tls --offline --no-offline --preview --no-preview --show-settings --no-progress --directory --project --config-file --no-config --help --version'
+ [[ ./ == -* ]]
+ [[ 2 -eq 2 ]]
+ COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
++ compgen -W '-m -s -i -f -U -P -C -p -n -q -v -h -V --extra --all-extras --no-all-extras --dev --no-dev --group --no-group --only-group --module --only-dev --no-editable --env-file --no-env-file --with --with-editable --with-requirements --isolated --no-sync --locked --frozen --script --index --default-index --index-url --extra-index-url --find-links --no-index --upgrade --no-upgrade --upgrade-package --reinstall --no-reinstall --reinstall-package --index-strategy --keyring-provider --allow-insecure-host --resolution --prerelease --pre --config-setting --no-build-isolation --no-build-isolation-package --build-isolation --exclude-newer --link-mode --compile-bytecode --no-compile-bytecode --no-sources --no-build --build --no-build-package --no-binary --binary --no-binary-package --refresh --no-refresh --refresh-package --all-packages --package --no-project --python --show-resolution --no-cache --cache-dir --python-preference --allow-python-downloads --no-python-downloads --python-fetch --quiet --verbose --no-color --color --native-tls --no-native-tls --offline --no-offline --preview --no-preview --show-settings --no-progress --directory --project --config-file --no-config --help --version' -- ./
+ exitHandler
+ exitCode=1
+ set +e
+ '[' -n '' ']'
+ ((  1 != 0  ))
+ runHook failureHook
+ local hookName=failureHook
+ shift
+ local 'hooksSlice=failureHooks[@]'
+ local hook
+ for hook in "_callImplicitHook 0 $hookName" ${!hooksSlice+"${!hooksSlice}"}
+ _logHook failureHook '_callImplicitHook 0 failureHook'
+ [[ -z '' ]]
+ return
+ _eval '_callImplicitHook 0 failureHook'
+ declare -F '_callImplicitHook 0 failureHook'
+ eval '_callImplicitHook 0 failureHook'
++ _callImplicitHook 0 failureHook
++ local def=0
++ local hookName=failureHook
++ declare -F failureHook
++ type -p failureHook
++ '[' -n '' ']'
++ return 0
+ for hook in "_callImplicitHook 0 $hookName" ${!hooksSlice+"${!hooksSlice}"}
+ _logHook failureHook _nix_shell_clean_tmpdir
+ [[ -z '' ]]
+ return
+ _eval _nix_shell_clean_tmpdir
+ declare -F _nix_shell_clean_tmpdir
+ _nix_shell_clean_tmpdir
+ command rm -rf /tmp/nix-shell-11729-0
+ return 0
+ '[' -n '' ']'
+ return 1

From what i can understand in the output:
it searches for uv
collects bin dirs from uv related packages?
looks in these bins for possible completions
and it results in it looking in command flags rather than paths
which makes it not find any valid param and exitcodes with 1
(do correct me if i am wrong, how i’ll learn)
should note that if there is no ./ it autocompletes a “-” automatically( makes sense considering the possible completions it looks in)

I do not understand how this is related to entering your shell.

Please use set -x only for the shell hook, to keep amount of printed information low.

Also, please use fenced or intended codeblocks when posting such a wall of preformatted text.

sry bout the unfenced code block, fixed that
above is the output in my shell when i do
nix-shell with this as the shell.nix file:

{ pkgs ? import { } }:

pkgs.mkShell {
buildInputs = [
pkgs.python311
pkgs.uv
];

shellHook = ‘’
set -ex
echo “Running shellHook…”
‘’;
}
I get this output(the problem isnt just entering, it is when tab completing a path):

+++ echo 'Running shellHook...'
Running shellHook...
+ return 0
+ unset NIX_ENFORCE_PURITY
+ shopt -u nullglob
+ unset TZ
+ shopt -s execfail
++ __zoxide_hook
++ builtin local -r retval=0
++ builtin local pwd_tmp
+++ __zoxide_pwd
+++ builtin pwd -L
++ pwd_tmp=/home/cake/Projects/scraperScholar
++ [[ /home/cake/Projects/scraperScholar != \/\h\o\m\e\/\c\a\k\e\/\P\r\o\j\e\c\t\s\/\s\c\r\a\p\e\r\S\c\h\o\l\a\r ]]
++ return 0

and running a command(only happens for uv or python, it seems) and tab completing a path(the actual problem):
uv run ./ and press tab
the only shellHook placed is set -ex ( the debug flag and the error flag that caused the problem).

set -e is a little weird to use for an interactive shell session. You’re inevitably going to do things that result in a non-zero status, and set -e makes any of those trigger an exit.

It’s a guess, but since it happens when you tab, I assume something in the completions is returning an unchecked non-zero status.

If you really want set -e here, I’d unset it at the end of the shellHook with set +e.

2 Likes

So, donyou mean, it’s not the shell hook that fails, but within your shell you have weird behaviour?

Try setting set +e at the end of the hook, and maybe similarly for the other flags if needed, and check if the unwanted behaviour still exists

1 Like

thanks for the help, really appreciate it.