When opening a terminal window on Ubuntu 24.04, I get this message:
bash: hash: hashing disabled
Its caused by this line:
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
It loads nvm
(https://github.com/nvm-sh/nvm).
Can I enable hashing?
Why may it be disabled?
If you're getting that message, it means that you have hashing disabled and that something in the script being sourced is running the
hash
built-in; in this specific case, that script is runninghash -r
twice, in order to forget all hashed commands in two different instances.This means that in this specific case hashing being disabled is not a problem for that specific script, as the script is trying to forget all hashed commands anyways; however, it brings up the fact that something else has disabled hashing prior to the script being sourced, something that might make sense in the context that's happening, but that usually doesn't make sense when using the shell normally, as usually you want hashing to be enabled.
So after having found out what's disabling hashing (a
set +h
command somehwere, either in~/.bashrc
/ another file sourced by interactive login shells / another file sourced by~/.bashrc
itself), re-enable hashing right after whatever task needs hashing to be disabled has been completed by running: