Git is not using the first editor in my $PATH

无人久伴 提交于 2019-12-12 19:50:24

问题


I am using OS X 10.8, and I used brew to install a more recent version of emacs than the one shipped with OS X.

The newer emacs binary is installed in /usr/local/bin (24.2.1), and the old "shipped-with-osx" one in /usr/bin (22.1.1).

I updated my $PATH env variable by prepending /usr/local/bin to it. It works fine in my shell (ie. typing emacs runs the 24.2.1 version), but when git opens the editor, the emacs version is 22.1.1.

Isn't git supposed to use $PATH to find the editor I want to use ?

Additional informations:

$ type -a emacs
emacs is /usr/local/bin/emacs
emacs is /usr/bin/emacs
emacs is /usr/local/bin/emacs
$ env
PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
SHELL=/bin/zsh
PAGER=most
EDITOR=emacs -nw
_=/usr/bin/env

Please note that I'd prefer not to set the absolute path of my editor directly in my git conf, as I use this conf across multiple systems.

EDIT: Here's an bit of my .zshrc:

# Mac OS X
if [ `uname` = "Darwin" ]; then
    # Brew binaries
    PATH="/usr/local/bin":"/usr/local/sbin":$PATH
else # Everyone else (Linux)
    # snip
fi

So, yes, I could add a line export EDITOR='/usr/local/bin emacs -nw' in the first if, but I'd like to understand why git is not using my PATH variable :)


回答1:


Installing git 1.8.0 fixed the issue.

Old version was 1.7.9.6 (Apple Git-31.1). This is weird as I didn't find any references to this kind of problem in the changelogs.




回答2:


The simplest fix is to set the full path in the environment variable.

OSX uses bash(1) by default, so stick export EDITOR=/usr/local/bin/emacs -nw somewhere in your .bash_profile to set the variable for all interactive bash shells.



来源:https://stackoverflow.com/questions/13301260/git-is-not-using-the-first-editor-in-my-path

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