Linux 单击选项卡时出现 shell init 问题,getcwd 有什么问题?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12338233/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 14:18:03  来源:igfitidea点击:

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

linuxbashshellpwdgetcwd

提问by hugemeow

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

一旦我在 bash 上单击 Tab,就会出现错误消息,这是怎么回事?

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?

如何解决shell初始化问题?

回答by Costi Ciudatu

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 cdto another (existing) directory and then cdback; the simplest would be: cd; cd -.

当您的当前目录不再存在时,通常会发生这种情况。最有可能的是,从另一个终端中删除该目录(从脚本中或其他任何内容中)。为了摆脱这种情况,如果您的当前目录在此期间被重新创建,只需cd到另一个(现有)目录然后cd返回;最简单的是:cd; cd -.

回答by Viraj Kulkarni

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.

是的,光盘;和 cd - 会工作。它可以看到的原因是,目录正在从任何其他终端或任何其他程序中删除并重新创建。因此 i-node 条目被修改,因此程序无法访问旧的 i-node 条目。

回答by Meetai.com

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

只需将目录更改为另一个目录并返回。可能那个已经被删除或移动了。

回答by jdknight

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

碰巧,这是否发生在使用 OverlayFS(或其他一些特殊文件系统类型)的目录上?

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

我刚刚遇到了这个问题,我的交叉编译版本的 bash 将使用一个内部实现,getcwd该实现的OverlayFS 有问题。我在这里找到了有关此的信息:

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

这似乎可以追溯到 bash 中 getcwd() 的内部实现。交叉编译时,它不能检查getcwd() 对malloc 的使用,因此谨慎并设置GETCWD_BROKEN 并使用getcwd() 的内部实现。这个内部实现似乎不适用于 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).

您可以使用bash_cv_getcwd_malloc=yes(如果您实际上是在构建 bash 并且您的 C 库执行 malloc 一个 getcwd 调用)来配置和重建 bash 。