160

once i click Tab on bash, the error message will appear, what's wrong?

symlink-hook: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
symlink-hook: error retrieving current directory: getcwd: cannot access parent directories: Success
symlink-hook: error retrieving current directory: getcwd: cannot access parent directories: Success
symlink-hook: error retrieving current directory: getcwd: cannot access parent directories: Success
symlink-hook: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
symlink-hook: error retrieving current directory: getcwd: cannot access parent directories: Success
symlink-hook: error retrieving current directory: getcwd: cannot access parent directories: Success
symlink-hook: error retrieving current directory: getcwd: cannot access parent directories: Success

sometimes, the error message is:

shell-init: error retrieving current directory: getcwd: cannot access parent directories: No s uch file or directory

how to solve shell init problem?

4 Answers 4

301

This usually occurs when your current directory does not exist anymore. Most likely, from another terminal you remove that directory (from within a script or whatever). To get rid of this, in case your current directory was recreated in the meantime, just cd to another (existing) directory and then cd back; the simplest would be: cd; cd -.

7
  • 3
    i don't think my dir is not exist, not someone have recreated it, i am in /root... so the issue maybe a bit different as your saying...
    – hugemeow
    Sep 9, 2012 at 14:24
  • 1
    can you check your HOME env variable ? echo $HOME; if that points to an unexisting location, that't it. Sep 9, 2012 at 15:57
  • 1
    (i use shell in tmux)Tab works well some times, but sometimes when i create new tab with tmux, press Tab, and this error appears, i don't know what happened:(
    – hugemeow
    Sep 15, 2012 at 18:39
  • @kevinarpe That's good to know, thanks! I always thought it was smart enough to do nothing on cd . May 27, 2015 at 7:18
  • 2
    @kevinarpe, yes, $PWD is guaranteed by POSIX to be defined. See pubs.opengroup.org/onlinepubs/9699919799/utilities/… Sep 3, 2015 at 16:38
69

Just change the directory to another one and come back. Probably that one has been deleted or moved.

0
7

By chance, is this occurring on a directory using OverlayFS (or some other special file system type)?

I just had this issue where my cross-compiled version of bash would use an internal implementation of getcwd which has issues with OverlayFS. I found information about this here:

It seems that this can be traced to an internal implementation of getcwd() in bash. When cross-compiled, it can't check for getcwd() use of malloc, so it is cautious and sets GETCWD_BROKEN and uses an internal implementation of getcwd(). This internal implementation doesn't seem to work well with OverlayFS.

http://permalink.gmane.org/gmane.linux.embedded.yocto.general/25204

You can configure and rebuild bash with bash_cv_getcwd_malloc=yes (if you're actually building bash and your C library does malloc a getcwd call).

1
  • I was able to fix my error by doing the full library updates Dec 15, 2017 at 22:28
6

Yes, cd; and cd - would work. The reason It can see is that, directory is being deleted from any other terminal or any other program and recreate it. So i-node entry is modified so program can not access old i-node entry.

1

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.