When I load a NixOS profile, I get warnings from bash
~ $ sudo nixos-rebuild test
building the system configuration...
activating the configuration...
setting up /etc...
reloading user units for jojo...
/home/jojo/.bashrc: line 9: complete: command not found
/home/jojo/.bashrc: line 10: shopt: histreedit: invalid shell option name
setting up tmpfiles
This comes from my (old, organically grown) .bashrc
that has these lines
complete -r
shopt -s checkwinsize histreedit failglob globstar
Digging a bit deeper it seems that the “reloading user units” thing runs a different bash: My normal system runs
~ $ readlink $(which bash)
/nix/store/bap4d0lpcrhpwmpb8ayjcgkmvfj62lnq-bash-interactive-5.1-p16/bin/bash
but during the above job it runs /nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin/bash
, judged from the name a non-interactive build of bash, and sure enough:
~ $ /nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin/bash
complete: command not found
bash: shopt: histreedit: invalid shell option name
It seems that build has certain interactive features disabled and thus I get these errors.
Now I wonder:
-
Did I place these settings in the wrong file
~/.bash_rc
? But the manpage for bash saysWhen an interactive shell that is not a login shell is started, bash reads and executes commands from
~/.bashrc
, if that file exists.so presumably it’s the right file.
-
Should that job somehow run the shell in non-interactive mode to avoid reading that file?
-
Or should I guard these command with some kind of check that tests if the current running
bash
is actually compiled with support for auto-completion and thehistreedit
option?
Can someone enlighten me?