Reputation: 563
Whenever I'm working in the command window, I get the error: "bash: __gitdir: command not found" right above the working line (in other words, right after any command, before it prompts for a new one).
Any ideas as to what is going on to bring this up?
Upvotes: 2
Views: 2085
Reputation: 4462
This will not exactly address the original question context, but might be useful for newer Ubuntu users migrating from older versions...
I recently upgraded an old Ubuntu 12.04 machine to newer version of Ubuntu and I started seeing errors about __git_dir
missing due to my PS1
settings like explained by the other answers. To understand why this shell function was not any more defined I figured my .bashrc
was not up-to-date with the newer Ubuntu conventions.
My old .bashrc
that was based on the one originally provided by old Ubuntu system had something similar to this:
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
while .bashrc
files created by newer Ubuntu systems first try to use /usr/share/bash-completion/bash_completion
:
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
When I replaced the old bash completion sourcing with the newer one, I got __git_dir
defined and was happy ever after.
Upvotes: 0
Reputation: 9759
The fancy git prompt may be enabled via the function __git_ps1
, which can be embedded in PS1
and called every time your prompt is printed. It's defined when sourcing a specific, but potentially different file than the one that defines __gitdir
. The __git_ps1
(which calls __gitdir
) could be in perhaps /etc/bash_completion.d/git-prompt
or /usr/share/git-core/contrib/completion/git-prompt.sh
or /etc/bash_completion.d/git
(etc)...
But if __git_ps1
ends up getting defined, but __gitdir
does not, then you would get this error (every time your prompt is printed). For example, if __gitdir
is defined in /etc/*
, but __git_ps1
is found in /usr/share/*
, then in a chroot env you may end up with __git_ps1
defined but __gitdir
not defined.
To "quiet" the error message, either remove the fancy git prompt, or just define it: __gitdir() { :; }
Upvotes: 0
Reputation: 10375
__gitdir
is a function supplied by the git-completion.bash
script that lets bash do auto-complete when you type git
commands. Are you using __gitdir
in your .bashrc
or other profile/login script without sourcing git-completion.bash
?
Upvotes: 6
Reputation: 23796
You probably have something calling that command in your .bashrc
file.
Try searching for __gitdir in it:
$ grep __gitdir ~/.bashrc
Or maybe post its content, and it will probably be easier to help.
Upvotes: 4