Unable to push to remote repos via https #255

Closed
bbatsov opened this Issue Aug 17, 2011 · 34 comments

Projects

None yet

8 participants

@bbatsov
bbatsov commented Aug 17, 2011

I'm using magit 1.0 with Emacs 23.3. I'm able to push to remote repos via ssh, but via https magit just hangs forever. I get no errors/messages. Older versions of magit asked me about my credentials so I assume that the problem has something to do with missing credentials.

Contributor
vanicat commented Aug 20, 2011

I've just tested it on current master, and magit did ask for my password.

Could you:

  • tell us what is your value for magit-process-connection-type, and
    test if the problem still exist with this variable set to t or to nil

  • test the last github version from master,

  • if all fail, confirm that the problem don't go away when you do

    M-x setenv SSH_ASKPASS ssh-askpass

bbatsov commented Aug 25, 2011

The value of magit-process-connection-type was t. Setting it to nil didn't fix anything. I'll try the github version later on and I'll let you know what happened.

bbatsov commented Aug 25, 2011

Tried the lastest version - no improvement.

Setting the SSH_ASKPASS manually causes git to exit with error code 128.

Owner
tarsius commented Apr 20, 2013

Please reopen if this still is an issue.

@tarsius tarsius closed this Apr 20, 2013
bjourne commented Aug 14, 2013

I'm getting the same problem on Windows with Emacs 24.3. *magit-process* says:

$ git --no-pager push -v origin improve-docs

Then just hangs there. The above command causes git to ask for username and password (since I'm pushing to a https repo), but magit doesn't seem to detect those questions being asked?

@tarsius tarsius reopened this Aug 14, 2013
bjourne commented Aug 15, 2013

Tested and works fine on Linux, but not on Windows though.

Owner
tarsius commented Aug 24, 2013

The above command causes git to ask for username and password.

I don't see git doing that in the *magit-process* buffer-string you posted above. Did you leave it out? That's the part we need to see to figure out what is going. The issue might be as easy to fix as modifying the regular expressions we use to detect prompts for user input.

bjourne commented Aug 24, 2013

Not sure what information you're missing. Tell me what you want me to copy-paste and I'll provide it.

Contributor
vanicat commented Aug 24, 2013

It seem git forget to flush stdout, so magit is waiting for git to send the messages, when git is waiting for its buffer to be full to send them, while waiting for the response to the question it didn't ask yet. If I'm correct it's a bug in git. On linux, I would test my hypothesis by running git --no-pager push -v origin improve-docs | cat on the command line, but I'm not sure what to do on windos. Did you try git --no-pager push -v origin improve-docs within eshell? not sure it will give us something interesting, but it worth the try.

Contributor
vanicat commented Aug 24, 2013

By the way, this look as a duplicate of #188

I can confirm the bug using Emacs 24.2.1 and magit 20130902.311.

Process output of magit-process

$ c:/Program Files (x86)/Git/cmd/git.cmd --no-pager push -v origin master
Pushing to https://....
Owner
tarsius commented Sep 4, 2013

I have closed the #852 because I am currently cleaning up magit-run* differently but I would still be interested in knowing whether #852 fixes this problem.

Contributor
npostavs commented Sep 4, 2013

#852 doesn't fix it. Tested on Windows Vista (64bit), emacs 24.3.1, git 1.8.1.msysgit.1, magit 18f267d (master) and then 13e9e1d (tarsius/runner), both hang before any prompt is printed.


A similar issue is gitextensions/gitextensions#85, they suggest setting core.askpass to git-giu--askpass. This means the prompting is done through a separate gui window which does allow magit to succeed. And also gitcredentialstore which might be of interest (I haven't tried it).

#852 does not work for me either.
the hint mentioned in gitextensions/gitextensions#85 to specify a user variable shows at least a pop-up requesting the password.

Current workaround is to add the mentioned environment variable to Windows (Start > right-click Computer > Properties > Advanced System Settings > Environment Variables > New under "User Variables for ..."):
Variable: GIT_ASKPASS
Value: git-gui--askpass

However I get the following error in magit-process

Pushing to https://user@bitbucket.org/user/project.git
error: src refspec master does not match any.
error: failed to push some refs to 'https://user@bitbucket.org/user/project.git'
c:/Program Files (x86)/Git/cmd/git.exe exited abnormally with code 1.
Owner
tarsius commented Sep 4, 2013

Pushing to https://user@bitbucket.org/user/project.git

Unless your username on bitbucket actually is user, the use of this dummy value might be the problem :-)

Owner
tarsius commented Sep 4, 2013

#852 doesn't fix it.

Well it was worth a try. I am not going to merge that pr. You can get its effect on windows with:

(setq magit-process-connection-type nil)

But since that didn't work...

Owner
tarsius commented Sep 4, 2013

The easiest way to add this kludge might be to add this to the init file.

(setenv "GIT_ASKPASS" "git-gui--askpass")

If that doesn't work use the full path to git-gui--askpass.

bjourne commented Sep 5, 2013

Success! That brings up a tk/inter dialog from OpenSSH that asks for username and password. Not as slick as on Linux where the prompt is shown in the mini-buffer, but it works. Pressing cancel in the dialog still hangs magit though.

Works for me too now! My initial error was due to a wrong .git configuration.

Owner
tarsius commented Sep 10, 2013

Cgywin users: could you please also try the opposite of what I suggested above: set magit-process-connection-type to t. Also unset GIT_ASKPASS and then let me know if it still works.

Owner
tarsius commented Sep 10, 2013

Reminder to self: once the above has been verified/falsified add a note to FAQ.

Owner
tarsius commented Sep 17, 2013

I have added this to https://github.com/magit/magit/wiki/FAQ now.

I discovered two other potential workarounds:

Please let as know if one of these options works for you, so that we can adjust the FAQ accordingly.

@tarsius tarsius closed this Sep 17, 2013
sprig commented Aug 11, 2014

I get a similar problem in magit-20140522.1128 and "GNU Emacs 24.4.50.1 (x86_64-w64-mingw32)
of 2014-05-21 on ALIMANTADO".

I have msysgit installed. If I open a gitbash shell and start & authenticate an ssh-agent there, and start emacs from that, then magit works (does not prompt for password). Otherwise, nothing happens.

I didn't think it would help, since I couldn't even find such a program on my system, but I tried using what was described in the FAQ and it didn't help...

Contributor

If I open a gitbash shell and start & authenticate an ssh-agent there, and start emacs from that, then magit works (does not prompt for password).

This sounds like you are using an ssh git url, not https. By "password" do you mean the one for your private key, or do you use password authentication to push to the remote?

I didn't think it would help, since I couldn't even find such a program on my system, but I tried using what was described in the FAQ and it didn't help...

By "it" do you mean "git-gui--askpass"? It should be at C:\Program Files\MSysGit\libexec\git-core\git-gui--askpass.

sprig commented Aug 11, 2014

Thanks for the reply!
I am indeed using an ssh url - I posted here simply because it seemed that all the other reports eventually got merged into this...

By password I mean the private key password. Thanks! I located git-gui--askpass eventually. setting SSH_ASKPASS did not change my situation although running manually the askpass program brings up a request for password.

Contributor

I posted here simply because it seemed that all the other reports eventually got merged into this...

Yeah, that's fine, it's just you were a bit vague.

setting SSH_ASKPASS did not change my situation

You also have to set the DISPLAY environment varible to some value. See this feature request (open since 2002!) about making this kludge unnecessary.

sprig commented Aug 12, 2014

Unfortunately, that does not help - I realize this may have nothing to do with magit anymore, since even if I sett GIT_ASKPASS and DISPLAY in git bash, I get prompted for a password at the console...

Owner
tarsius commented Aug 12, 2014

I didn't follow the above discussion, but this sounds like you do not have a ssh-agent running. So you have to type the pass- phrase again, because there is no agent around who has cached it for you. But I might be wrong.

And yeah configuring the ssh-agent is beyond magit's domain (and I wouldn't know how to do it on Windows anyway (but maybe someone else can help with that)). In any case the github documentation linked to in the FAQ probably has more information about it.

Contributor

since even if I sett GIT_ASKPASS and DISPLAY in git bash

It's SSH_ASKPASS, not GIT_ASKPASS, that requires DISPLAY. Except that's not enough, on Windows one needs to set DETACHED_PROCESS flag (found about this from here, confirmed by testing with a little C program), so this can't be done directly with Emacs or a terminal :(

In any case the github documentation linked to in the FAQ probably has more information about it.

They suggest running ssh-agent, so that "when you first run Git Bash, you are prompted for your passphrase", and you won't be prompted again. But if the first run is from magit...

sprig commented Aug 12, 2014

Alright, I managed to get it to more or less as pleasantly as in linux. I will publish the details elsewhere, but here too for the benefit of future travelers:

I installed gpg4win, and in the "backend preferences" of GPA set enable-putty-support.
I installed putty
I imported my existing ssh key into the ppk format using puttygen
I ran "path/to/pageant.exe" path/to/id_rsa.ppk There I was prompted for a password to unlock the key and then for a password to store it in gpg-agent
Finally, I set the GIT_SSH to path/to/plink.exe

Henceforth when emacs starts I am prompted graphically for my gpg key to unlock some credentials, and am prompted graphically for my ssh key password when it is relevant (i.e. when doing a first time git pull in magit in a login session).

Thanks for the quick and helpful responses!

drozzy commented Apr 12, 2015

Push does nothing on windows... I am using ssh-based authentication (to github). It just hangs there.

Contributor

Push does nothing on windows... I am using ssh-based authentication (to github). It just hangs there.

Does it work from the command line? Have you followed the instructions in https://github.com/magit/magit/wiki/FAQ#windows-cannot-push-with-ssh-passphrase?

drozzy commented Apr 21, 2015

@npostavs I am not sure what that does.

Contributor

@drozzy: sorry for really delayed response, if you are still interested in fixing this, I have written OpenSSH passphrase caching, via ssh-agent, which is an expanded version of the FAQ I linked, including some troubleshooting guidelines. Take a look and see if it helps (and if it doesn't, how can it be improved to be more helpful).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment