Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
673 views
in Technique[技术] by (71.8m points)

macos - "git pull" broken

I recently upgraded my MacBook Pro to Snow Leopard and "git pull" returns:

rakudo $ git pull
git: 'pull' is not a git-command. See 'git --help'

Did you mean this?
        shell
rakudo $ git-pull
-bash: git-pull: command not found

I've tried reinstalling via macports, but to no avail. Then I saw this

rakudo $ git --exec-path
/Users/ovid/libexec/git-core

That surprised me as that directory does not exist, nor has it ever existed. Google is not helping here. Hopefully you can :)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Looking in the source of git, there's a comment in git.c:

/*
 * We use PATH to find git commands, but we prepend some higher
 * precedence paths: the "--exec-path" option, the GIT_EXEC_PATH
 * environment, and the $(gitexecdir) from the Makefile at build
 * time.
 */

If you call git --exec-path, you end up calling const char *git_exec_path(void) in exec_cmd.c. That looks like this:

const char *env;

if (argv_exec_path)
    return argv_exec_path;

env = getenv(EXEC_PATH_ENVIRONMENT);
if (env && *env) {
    return env;
}

return system_path(GIT_EXEC_PATH);

Now, _argv_exec_path_ is set when you say --exec-path=/some/where so can be discounted. You've stated that the environment variable isn't set. GIT_EXEC_PATH is defined during compilation in the Makefile. Going backwards, it seems to be defined as just libexec/git-core. So, we need to look at what system_path() does instead.

I'm not sure whether RUNTIME_PREFIX is defined for you. But while nosing in the Makefile, I did notice that prefix defaults to $(HOME). I suspect that this may be the cause of your problems.

The simple answer is to put this in ~/.bashrc:

export GIT_EXEC_PATH=/opt/local/libexec/git-core

If you want to find out more about what's going on, you'll probably have to recompile git using port -d upgrade -f git-core (or similar) and look closely at the build log to see where prefix is being set. Incidentally, port cat git-core shows heavy usage of ${prefix} so it should (hopefully) be obvious.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...