Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm getting a 'permission denied' error on a git alias. It works with root but not my user account:

$ andy@ubuntu:/usr/local/bin$ sudo git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
$ andy@ubuntu:/usr/local/bin$ git lg
    fatal: cannot exec 'git-lg': Permission denied
$ andy@ubuntu:/usr/local/bin$

Any Ideas?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

There's an entry in your $PATH pointing to a directory that you can't access, and you're using a version of git earlier than 1.7.10.1.

When you run git lg git first does some setup, including adding an entry to the copy of the $PATH that it is using. Then it tries to run the command git-lg, so that a command would override the alias. When it does that it's getting the permission denied error shown in your output.

Older versions of git would stop at that point. Starting with version 1.7.10.1, it will treat that error the same as the command just not being found.

When you ran that as root git was able to look through all of the directories in the $PATH, see that no git-lg command exists, and so it would go on to use the defined alias.

To fix the problem you can upgrade to a newer version of git. The other option would be to make sure that you have permission to access all directories listed in your $PATH, either by granting additional permissions on any that are a problem or by not including those in the list.

share|improve this answer
    
Thank you! It appears, after rebooting, I can now use the command –  andy Feb 22 '13 at 15:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.