Closed zvaehn closed 7 years ago
Auto Git detects if a remote has been setup by running git remote get-url <remote-name>
. Could you please cd
into your installation and run this command? What's the output?
git remote get-url origin
is not working for me (git 2.1.3)
I used git remote show origin
instead:
I just found out that git remote get-url
is a Git 2.6+ feature. I'm not sure if git remote show
could be a replacement because it actually hits the remote to get this information. Maybe caching the response might do the trick, I need more time to experiment with this.
Does replacing autogit()->hasRemote()
for true
on this line makes it work for you?
yes :)
Great!
There have been some SSH key authorisation issues and I haven't found a good solution yet. Sometimes a command that runs from terminal doesn't run from PHP 😞
I'll leave this open and try to fix it by supporting the oldest Git version possible.
Thank you! I can work with it right now.
I had the same issue (with Git 2.6.4) as @zvaehn and changing the autogit()->has Remote()
to true
enabled the widget, but pulling/pushing changes still does not work. Any ideas why?
Thanks & Best,
Matt
@Mattrushka I have a few question in order to better help you:
1) Are you using the panel on server or local machine? 2) Are you able to push/pull from command line?
If the answer to question 2 is no, you may need to setup a SSH key. Otherwise, it might be that the user running the PHP process does not have permission to access the SSH key. Can you confirm if that's the case?
@pedroborges thanks for the feedback! 1) I am using the panel on both, local server and remote machine, and both show the same error. 2) Push/Pull/Deploy to live — everything works like a charm from command line.
I checked my SSH key settings (https://help.github.com/articles/testing-your-ssh-connection/) and a SSH key is setup and I am successfully authenticated. Are there more ways to check if the running PHP process has permission to access the SSH key?
Maybe some information about my setup:
content
folder is not on the ignore list of my repositoryYour setup seams to be correct, the content
folder shouldn't be ignored.
In order to know which user is running the PHP process, please run the code below and make sure that that user has permission to read the ssh key:
<?php
exec('whoami', $output, $returnValue);
echo $output;
I checked the whoami
and the users are identically.
I have not deep dived into your code, but are there any options to echo the reason for the error?
When there's an error message from the executed command it is shown below the button, otherwise it shows the generic Something thing went wrong message.
Unfortunately no error message is shown inside the widget for me, neither locally nor on the server. Just the feedback I posted with the screenshot :(
@Mattrushka I might have found our culprit. I also have a similar problem on my local machine. Auto Git pull and push works fine on my server though.
I tried running different commands from PHP to see what worked and what didn't:
<?php
exec('git --version', $output);
var_dump($output); // outputs: git version 2.9.0
exec('ssh-add -l', $output);
var_dump($output); // outputs nothing
Digging deeper I found that they are on different paths:
$ which php
# /usr/local/bin/php
$ which git
# /usr/local/bin/git
$ which ssh
# /usr/bin/ssh
# same for ssh-add and so on…
$ ls -l /usr
# ...
# drwxr-xr-x 1054 root wheel 35K Jul 24 08:39 bin # ssh, ssh-add, …
# drwxrwxr-x 21 pedro admin 714B Jul 28 08:32 local # php and git
# ...
I tried it on another machine where these binaries have the same permission and it worked. My guess is that PHP can only exec
commands that are also owned by its owner.
I'm not so sure how to fix these without messing with the system but I will look a bit more when I get time. If anyone here knows how to, I'd love to add it to the documentation to help others.
@pedroborges great deep dive & analysis of the problem - many thanks! it sounds reasonable, although it goes way beyond my knowledge. so unfortunately I can't help fixing the issue. I think for now I will have to remove the plugin, because otherwise I will mix up my git and site. but I will watch the discussion here and hope to see a fix, as this plugin definitely has value.
I'm unable to update git on the web server I'm working on (shared hosting), and have had to made a small change to fix the 'get-url' issue:
From:
$this->execute('remote get-url "' . $remoteName . '"');
To:
$this->execute('config --get remote.' . $remoteName . '.url');
This syntax works fine on the newest version of Git I believe.
Thanks, I'll will use your solution on the next version.
Hi there, I am experiencing the same error as described above. I am running kirby under runcloud.io.
$ which php
# /RunCloud/Packages/php72rc/bin/php
$ which git
# /usr/bin/git
$ which ssh
# /usr/bin/ssh
<?php
echo get_current_user();
?>
# runcloud
I can add, commit and push using e.g. sudo -H -u runcloud bash -c "git push"
to run git as the user who is running php.
git remote get-url origin
returns the right origin.
I also tried to change the user and group of /usr/bin/git
to runcloud
but didn't have an effect.
So everything seems to work but still I cant use the widget. Do you have any idea?
I setup a fresh Kirby installation (2.3.1) and installed this plugin via git-submodule. I added the remote origin, but the widgets keeps saying:
Any ideas what i did wrong? Best, Sven