git 无法执行编辑器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4092432/
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
Could not execute editor
提问by Rob Wilkerson
I don't often have to modify multiple commit messages, but it has happened once or twice and I don't ever remember seeing this. I hope someone else has. When I git rebase -i HEAD~7
, the expected list opens in vi exactly as expected. I change the pick
values to edit
where appropriate and then :wq
.
我不需要经常修改多个提交消息,但它发生过一两次,我不记得看到过这个。我希望别人有。当 I 时git rebase -i HEAD~7
,预期列表完全按预期在 vi 中打开。我将pick
值更改为edit
适当的地方,然后:wq
.
Could not execute editor
无法执行编辑器
The core.editor
setting in my global .gitconfig
is vi
(I've also changed it to vim
in a wildly desperate move). I tried using mate
, but that didn't even open the initial list properly so I changed it back.
将core.editor
在我的全局设置.gitconfig
是vi
(我也改成了vim
在绝望的疯狂举动)。我尝试使用mate
,但这甚至无法正确打开初始列表,因此我将其改回。
I'm using v1.7.3 and would welcome any suggestions.
我正在使用 v1.7.3,欢迎提出任何建议。
回答by Rob Wilkerson
Yesterday was just one of those days. On a lark, I decided to set the full path to vi (e.g. /usr/bin/vi
) rather than just the executable. Now everything works. I have to admit that I don't get it since vi
is perfectly executable on its own (my $EDITOR
env variable is also set to vi
), but it's working and my technical karma hasn't been so great lately so maybe I just shouldn't question the deities will...
昨天只是那些日子之一。顺便说一句,我决定设置 vi(例如/usr/bin/vi
)的完整路径,而不仅仅是可执行文件。现在一切正常。我不得不承认我没有得到它,因为vi
它本身是完全可执行的(我的$EDITOR
env 变量也设置为vi
),但它正在工作,而且我的技术业力最近不太好,所以也许我不应该质疑神明会...
回答by Langusten Gustel
The following command
以下命令
git config --global core.editor /usr/bin/vim
fixes it.
修复它。
[edit]
[编辑]
Now I see that someone already posted it in the comments. Hope its still helpful for some blind folks like me.
现在我看到有人已经在评论中发布了它。希望它对我这样的盲人仍然有帮助。
回答by LarsH
Unlike with the other answers here so far, for me using the absolute path to vi, and setting the git core.editor
config, were not sufficient to solve the problem. (Those were already in place.)
与到目前为止的其他答案不同,对我来说,使用 vi 的绝对路径并设置 git core.editor
config 不足以解决问题。(那些已经就位。)
In my situation, the problem was solved by adding the -f
flagto the vi command:
在我的情况下,问题是通过在 vi 命令中添加-f
标志来解决的:
git config --global core.editor '/usr/bin/vi -f'
Once this -f
option is in place, I can use git rebase -i
, and when I save-and-exit the commit list, the rebase proceeds as it should instead of giving the "could not execute editor" error.
一旦这个-f
选项到位,我就可以使用git rebase -i
, 并且当我保存并退出提交列表时,rebase 会按它应该的方式进行,而不是给出“无法执行编辑器”错误。
The vim man pagesays with regard to option -f
,
该VIM手册页说,对于选项-f
,
For the GUI version, Vim will not fork and detach from the shell it was started in. ... This option should be used when Vim is executed by a program that will wait for the edit session to finish (e.g. mail).
对于 GUI 版本,Vim 不会从它启动的 shell 中分叉和分离。 ... 当 Vim 由等待编辑会话完成的程序(例如邮件)执行时,应该使用该选项。
Well I'm not using a GUI version, that I know of. I'm running git
at the bash command line in a terminal window on masOS Sierra 10.12.6. But since git rebase -i
waits for the edit session to finish, I suppose that's why the -f
option is necessary here. Maybe vim (without -f
) tries to fork/detach from the shell for some reason I haven't been able to figure out.
好吧,我没有使用我知道的 GUI 版本。我git
在 masOS Sierra 10.12.6 的终端窗口中运行bash 命令行。但是由于git rebase -i
等待编辑会话完成,我想这就是为什么-f
这里需要该选项的原因。也许 vim (没有-f
)由于某种我无法弄清楚的原因试图从外壳中分叉/分离。
回答by Annika Backstrom
I had this issue, and it was caused by some part of the vcscommand plugin for vim. Starting vim with any of these commands resulted in exit code 1 ("error"):
我遇到了这个问题,它是由 vim 的 vcscommand 插件的某些部分引起的。使用这些命令中的任何一个启动 vim 都会导致退出代码 1(“错误”):
vi
vim
vi
vim
But these gave me exit code 0 ("success"):
但是这些给了我退出代码 0(“成功”):
/usr/bin/vi
/usr/bin/vim
vi -u NONE
vim -u NONE
/usr/bin/vi
/usr/bin/vim
vi -u NONE
vim -u NONE
I was able to trace it back to the specific plugin by disabling ~/.vimrc
and files in ~/.vim
by renaming them and running vi -c q ; echo $?
to quickly run vim and print the exit code.
我能够通过禁用~/.vimrc
和~/.vim
重命名文件并运行vi -c q ; echo $?
以快速运行vim并打印退出代码来将其追溯到特定插件。
回答by Clay Bridges
For me, it was a problem with my .vimrc. Temporarily renaming that file fixed it. Followed by debugging my .vimrc. This is very similar to ignu's experience.
对我来说,这是我的 .vimrc 的问题。临时重命名该文件修复了它。其次是调试我的 .vimrc。这与ignu的经历非常相似。
回答by alphapilgrim
If you wanted to for whatever reason use sublime you could do something like the following in your global config file:
如果您出于任何原因想使用 sublime,您可以在全局配置文件中执行以下操作:
git config --global core.editor "/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"
回答by techkuz
Another option is to use nano
editor.
另一种选择是使用nano
编辑器。
$ whereis nano
$ git config --global core.editor path/to/nano
$ whereis nano
$ git config --global core.editor path/to/nano
Fixes it.
修复它。
回答by MasterJoe2
I was trying to squash commits as shown here https://www.youtube.com/watch?v=V5KrD7CmO4o. My git editor (notepad++) opened up in the rebasing step. But, in the amend commit message step, I saw the "Could not execute editor" issue. It probably happened because the git editor settings were wrong and also because I installed notepad++ in a non-standard location on my windows system. That is, 'git config core.editor' gave me notepad++ -multilnst- nosession
.
我试图压缩提交,如下所示https://www.youtube.com/watch?v=V5KrD7CmO4o。我的 git 编辑器 (notepad++) 在变基步骤中打开。但是,在修改提交消息步骤中,我看到了“无法执行编辑器”问题。这可能是因为 git 编辑器设置错误,还因为我在 Windows 系统上的非标准位置安装了 notepad++。也就是说,'git config core.editor' 给了我notepad++ -multilnst- nosession
.
To fix the issue, provide full path like this :
要解决此问题,请提供如下完整路径:
git config --global core.editor "'C:\CustomFolder\NPP\notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
回答by ignu
It just took me a while to track down my problem to one of my plugins.
我花了一段时间才找到我的一个插件的问题。
(specifically, it was https://github.com/ervandew/supertab)
(具体来说,它是https://github.com/ervandew/supertab)
I guess that's the downside to automatically updating all my plugins.
我想这是自动更新我所有插件的缺点。
So best advice, disable half your vimrc and plugins. If that doesn't help, the problem's with your other half.
所以最好的建议是,禁用一半的 vimrc 和插件。如果那没有帮助,问题出在你的另一半身上。
回答by Eben Geer
Oddly enough, just trying it again worked for me.
奇怪的是,再试一次对我有用。
My core.editor and $EDITOR variables are not set.
我的 core.editor 和 $EDITOR 变量没有设置。