How can I fix Edit cancelled, no changes made in shell

落花浮王杯 提交于 2020-12-08 06:28:05

问题


I run

kubectl edit deployment

to change the version of one of my pods (this commands opens a temp file in my text editor and then I usually edit and close this temp file) and even before I close this temp file in my text editor I can see the following note in my bash.

Edit cancelled, no changes made.

It was OK before I installed fish and I tried to switch to bash but it doesn't help either.

How can I fix it?


回答1:


Things like this are most likely caused by it opening an editor that forks off instead of staying.

That means you'll want to set $EDITOR to an editor that does wait. E.g. nano, vim or emacs should work, and e.g. if you use sublime text you'll have to use subl -w to explicitly tell it to wait.

It's not quite clear which shell you're running at the moment. If it's bash, run export EDITOR="subl -w", in fish run set -gx EDITOR subl -w (or "subl -w" if you use fish < 3.0).




回答2:


A refinement to the ample answer provided by @faho.

An approach with the $EDITOR variable achieves the goal but changes the default command-line editor. This might affect other programs dependent on this setting (e.g. crontab, edquota).

It'd be better to rely on the $KUBE_EDITOR variable. For example for the one-time use you might try:

KUBE_EDITOR="nano" kubectl edit deploy/hello-world

(Please see Editing Resources)



来源:https://stackoverflow.com/questions/56811177/how-can-i-fix-edit-cancelled-no-changes-made-in-shell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!