Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to setup gitolite using the "directly on the server method" in the docs

Went through the entire setup, uploading the ssh public key etc... so now I can ssh git@myserver without prompting me for any passwords, all good.

I reached this step that I need to perform on my workstation, in my case a Mac OS

on the client, run cd; git clone git@server:gitolite-admin

running that is throwing this error:

Initialized empty Git repository in /Users/myLocalUser/gitolite-admin/.git/
bash: git-upload-pack: command not found
fatal: The remote end hung up unexpectedly

which tells me that it cannot find git-upload-pack, so I thought I would just have to add its path to the "git" user ".profile"

I just double checked and the path is there! if I:

ssh git@myServer

then call:

which git-upload-pack

I get the path as expected:

/usr/local/bin/git-upload-pack

What am I missing here?!

I can't seem to clone gitolite-admin, because of it keeps complaining about not being able t find git-upload-pack!!

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

Finally I got this solved by adding the PATH to .bashrc instead of .profile

git user is set to use /usr/bin/bash shell

I haven't realized that when I ssh to my server with user git:

ssh git@myServer

the PATH variable is being read from .profile in git's home directory.

echo $PATH

was displaying all the right paths included in .profile

but..

from my wrokstation, when I tried

ssh git@myServer \echo $PATH

the output was completely different, and the paths were all missing.

After adding .bashrc file to git's home directory, and defined all PATHs I needed inside .bashrc, and added /usr/local/bin/ where git-upload-pack is sitting, it worked as expected.

Always make sure the paths have been set where they should have been by running this command:

ssh git@myServer \echo $PATH
share|improve this answer
    
A quick note: If your remote shell is not bash but zsh, use .zshenv instead of .bashrc –  chiborg Jun 14 '12 at 11:48
add comment

When you log in to a machine with ssh it starts a "login shell" and some of your login scripts are executed. If you remote execute a command with ssh, some other login scripts are executed. You can read about this here.

Your problem is (as you figured out) that the path to git-upload-pack is not set for the "non-login" shell.

You can either change the login scripts as you suggested. A perhaps simpler alternative is to specify the path to git-upload-pack on the command line like this:

git clone --upload-pack /usr/local/bin/git-upload-pack git@server:gitolite-admin

If you have a remote repository for which you have to use the --upload-pack a lot, you can make life easier by configuring git after the clone to always use that path for that repository

git configure remote.<name-of-repo>.uploadpack /usr/local/bin/git-upload-pack

Unless you named your remote repository, the <name-of-repo> is usually origin

share|improve this answer
add comment

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.