I've read this answer about eight-five times, but there's something I'm not understanding correctly:
git-upload-pack: command not found, how to fix this correctly
When I try to clone a repository on my server, I get the following:
bash: git-upload-pack: command not found
But when I clone by giving clone the -u /usr/local/bin/git-upload-pack
option, all works well.
I guess this makes sense, since that's the position of the git-upload-pack on my server.
The top answer suggests my .bashrc file on server needs to be updated to reflect this, as the result of ssh you@remotemachine echo \$PATH
does not return /usr/local/bin
. (It returns /usr/bin:/bin:/usr/sbin:/sbin
).
But when I look at my .bashrc file, it contains:
export PATH=/usr/local/bin:$PATH
So now I'm confused.
What do I need to do to avoid using the -u /usr/local/bin/git-upload-pack
option every time? Why does ssh you@remotemachine echo \$PATH
not return /usr/local/bin
? Is this something to do with login and non-login shells?
Please help! Thanks in advance.
This is connected to this issue:
https://serverfault.com/questions/130834/svnssh-getting-bash-to-load-my-path-over-ssh
Ssh is not loading your environment by default when sending a command without going to interactive mode.
good solution is the one with .ssh/environment file:
in /etc/ssh/sshd_config add:
PermitUserEnvironment yes
Then just create .ssh/ directory and dump envronment to .ssh/enviroment:
cd ~/ mkdir .ssh env > .ssh/environment
Restart SSH
/etc/init.d/sshd restart
Now when you do this from your local machine:
ssh [email protected] "which git-upload-pack"
you s'd get
/usr/local/bin/git-upload-pack
and git clone s'd work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With