shell init issue when click tab, what's wrong with getcwd?

LinuxBashShellPwdGetcwd

Linux Problem Overview


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?

Linux Solutions


Solution 1 - Linux

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 -.

Solution 2 - Linux

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

Solution 3 - Linux

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).

Solution 4 - Linux

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionhugemeowView Question on Stackoverflow
Solution 1 - LinuxCosti CiudatuView Answer on Stackoverflow
Solution 2 - LinuxMeetai.comView Answer on Stackoverflow
Solution 3 - LinuxjdknightView Answer on Stackoverflow
Solution 4 - LinuxViraj KulkarniView Answer on Stackoverflow