Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git repository with authentication: could not read Username - bash: /dev/tty: No such device or address #327

Closed
ghost opened this issue Aug 28, 2015 · 29 comments

Comments

@ghost
Copy link

ghost commented Aug 28, 2015

Hi,

I met a strange behavior. We have a git repository that requires a user/password (or a SSH key) to clone a project repository. Cloning directly works, but when I try through command line tools like Cordova, bower... that uses git to get a component, I get error messages with the latest git (2.5, 2.4.6, 2.4.5...), but I have no error with git 1.9.5 (previous official git for Windows).

I tested on multiple Windows 7 and multiple Windows 8, same behavior (KO with recent git, OK with 1.9.5).

With bower: bower install https://my-repo-with-password.com/group/my-lib.git

C:\myProjectPath>bower install https://my-repo-with-password.com/group/my-lib.git
bower my-lib#*    not-cached https://my-repo-with-password.com/group/my-lib.git#*
bower my-lib#*       resolve https://my-repo-with-password.com/group/my-lib.git#*
bower my-lib#*       ECMDERR Failed to execute "git ls-remote --tags --heads https://my-repo-with-password.com/group/my-lib.git", exit code of #128 bash: /dev/tty: No such device or addres
s error: failed to execute prompt script (exit code 1) fatal: could not read Username for 'https://my-repo-with-password.com': No error

Additional error details:
bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://my-repo-with-password.com': No error

With cordova: bower install https://my-repo-with-password.com/group/my-lib.git

C:\myProjectPath>ionic plugin add https://my-repo-with-password.com/group/my-cordova-plugin.git
Updated the hooks directory to have execute permissions
Fetching plugin "https://my-repo-with-password.com/group/my-cordova-plugin.git" via git clone
Failed to fetch plugin https://my-repo-with-password.com/group/my-cordova-plugin.git via git.
Either there is a connection problems, or plugin spec is incorrect:
        Error: C:\Program Files\Git\cmd\git.exe: Command failed with exit code 128 Error output:
Cloning into 'C:\Users\ORY-LA~1.ANT\AppData\Local\Temp\git\1440747212231'...
bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://my-repo-with-password.com': No error

Any idea about what could be wrong?

Thanks!

PS: Reaching with SSH does not work (bower install [email protected]:group/my-lib.git or ionic plugin add [email protected]:group/my-cordova-plugin.git) does not work, but that may be another issue since it does not work with git 1.9.5 as well.

@dscho
Copy link
Member

dscho commented Aug 28, 2015

Which options did you choose when installing? Does it work from Git Bash? Does it work from Git Bash if you choose ConHost? What if you run it with winpty (as suggested in the Known Issues)?

Also: could you maybe come up with a minimal example that reproduces the issue? I.e. some Javascript one-liner that calls git clone with a non-existing repository on GitHub to cause a prompt?

@vital055
Copy link

We have a similar problem. In our case git commands are run from a perl script and we need to capture stdout and stderr. With msysgit 1.9.5 we had no problems. But with the new version 2.5.0 we are getting the same error:
bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
I tried with git bash - the same result. winpty does not help. It is easy to reproduce with the following one-liner: perl -e "$out=git clone <repo> 2>&1;print $out" , where is URL of GIT repo, requiring authentication (http, https or ssh protocols). 2.5.0 has problems displaying
"Username for :" , whereas 1.9.5 does not.

@vital055
Copy link

PS: in the one-liner above backticks seem to have disappeared:
perl -e "$out=qx(git clone 2>&1);print $out"

Thank you for any help.

@dscho
Copy link
Member

dscho commented Aug 28, 2015

@vital055 I'll do my famous imitation of a broken record 😼

Which options did you choose when installing? Does it work from Git Bash? Does it work from Git Bash if you choose ConHost? What if you run it with winpty (as suggested in the Known Issues)?

@vital055
Copy link

Thanks for looking at this...

Which options did you choose when installing? 

I tried many possible option combinations, i.e. Windows Explorer intergration and w/o, use Git from Windows or Windows and Unix optional tools, 
use MinTTY or Windows default console...I also tried both 32bit and 64 bit versions..
In both Git bash and Win cmd - the same error. Winpty does not help.
As for " Git Bash if you choose ConHost" - I do not know exactly whta you mean - how to choose ConHost in GitBash?

Regards, vital055

Пятница, 28 августа 2015, 9:39 -07:00 от Johannes Schindelin [email protected]:

@vital055 I'll do my famous imitation of a broken record
Which options did you choose when installing? Does it work from Git Bash? Does it work from Git Bash if you choose ConHost? What if you run it with winpty (as suggested in the Known Issues)?

Reply to this email directly or view it on GitHub .

@ghost
Copy link
Author

ghost commented Aug 31, 2015

@dscho @vital055 Thanks for answering. It seems that vital055 tested more than me.

I installed with the default options, except adding git in the PATH. I will try with the git bash and winpty later, but it seems it does not help for vital055.

@dscho
Copy link
Member

dscho commented Aug 31, 2015

@aorylamballe since @vital055 already addressed my questions, I would appreciate it more if you came up with that MCVE I have been asking for than if you re-tested with Git Bash and winpty.

@ghost
Copy link
Author

ghost commented Sep 2, 2015

Hi @dscho,

The on-line command @vital055 provided reproduces the issue for me as well:

perl -e "$out=qx(git clone https://innersource.accenture.com/rebar-mobile-eso/rebar-mobile-eso-antoine.git 2>&1);print $out"

This should prompt the username / password, but instead displays the same error message:

Cloning into 'rebar-mobile-eso-antoine'...
bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://innersource.accenture.com': No error

git clone directly used on the shell works, but not through bower, ionic... and not through perl apparently.

Further tests:

  • In Windows cmd:
    • bower: the previously reported error
    • perl wrapper: same error
    • winpty: is not a recognized command
  • In git bash:
    • bower: same error
    • perl wrapper: no output (returns almost instantly)
    • winpty: no better result (for both previous commands)
  • In Windows PowerShell:
    • bower: same error
    • perl wrapper: no output as well
    • winpty: is not a recognized command

I don't know as well what is ConHost nor how to use it.

Thanks.

@dscho
Copy link
Member

dscho commented Sep 2, 2015

The on-line command @vital055 provided reproduces the issue for me as well

That might be a different issue, though... So I'd still be interested in that Javascript MCVE so I can be certain that I debug and fix the original bug.

I don't know as well what is ConHost nor how to use it.

It is one option in the installer as terminal emulator to use with Git Bash; the other one is mintty.

@ghost
Copy link
Author

ghost commented Sep 2, 2015

Bower reproduces the problem, so I checked its source code and extracted the code to execute git. The following node script reproduces the error:

#!/usr/bin/env node
'use strict';

var cp = require('child_process');

executeCmd('git', ['clone', 'https://innersource.accenture.com/rebar-mobile-eso/rebar-mobile-eso-antoine.git']);

function executeCmd(command, args, options) {
    var process = cp.spawn(command, args, options);
    var stdout = '', stderr = '';
    process.stdout.on('data', function (data) { stdout += data; });
    process.stderr.on('data', function (data) { stderr += data; });
    process.on('close', function (code) {
        console.log(stdout);
        console.error(stderr);
    });
}

ConHost installation option does not change anything, it continues to behave the same as the Windows cmd, same error.

This script is not enough to clone successfully with version 1.9.5, something might be missing I didn't find in the bower source (the program logs nothing and never exits), but it works with bower install ..., so that's a way to check if it is solved.

@dscho dscho self-assigned this Sep 2, 2015
@dscho
Copy link
Member

dscho commented Sep 2, 2015

@aorylamballe thank you for the MCVE. I will check it out as soon as I am done with some other tickets, and hopefully will have a good idea how to fix the problem.

@ghost
Copy link
Author

ghost commented Sep 4, 2015

Thanks for your help :)

@dscho
Copy link
Member

dscho commented Sep 24, 2015

Sorry to let this slip for so long. In the meantime, it has unfortunately become even more difficult to fix because we now launch node through winpty to pretend to node that we have a proper Win32 console. I am not sure that I will manage to force-allow /dev/tty access to the Bash launched through Git, which gets launched through node, which gets launched through the WinPTY agent, which gets launched through winpty, which finally gets launched from the Bash that actually has /dev/tty access.

In the meantime, I got another idea, though: could you test whether this works?

export DISPLAY=required
export SSH_ASKPASS=/mingw64/libexec/git-core/git-gui--askpass
export GIT_ASKPASS=$SSH_ASKPASS
node ...

@dscho dscho added the bug label Sep 24, 2015
@dscho
Copy link
Member

dscho commented Nov 9, 2015

could you test whether this works?

@aorylamballe could you?

@vital055
Copy link

Unfortunately, the problem remains, in that I am still getting "bash: /dev/tty: No such device or address" error - with version 2.6.3 I also tried $GIT_ASKPASS and $SSH_ASKPASS variables - suggested above.. to no avail...

@dscho
Copy link
Member

dscho commented Nov 13, 2015

@vital055 at this point, I cannot focus on this ticket anymore, so I will have to suggest that you try to debug this yourself. In particular, you need to find out where /dev/tty is attempted to be accessed. That means that you have to figure out which program actually outputs the error message, and if it is a script, make sure that set -x is executed at the beginning of said script.

@antoineol
Copy link

@dscho @vital055 Sorry for my very late response, I was busy recently.

I retried with git version 2.6.2.windows.1, and bower install ... in CMD still does not work, but it does work inside the git bash!

So we have a workaround, getting the latest version of git (not sure this is the reason) and installing the bower dependency in the project using git bash.

It is not convenient since all other usecases I have met with git so far work in CMD (webstorm has an embedded CMD very convenient), but at least it means we can finally stop using git 1.9.5 (which has other issues with TFS git).

@vital055, does this inspire you something?

Thanks!

@dscho
Copy link
Member

dscho commented Apr 2, 2016

I am closing this ticket because we now ship the Git Credential Manager and enable it by default (and then this issue does not occur, but instead the Credential Manager asks for credentials interactively, I just tested this).

@dscho dscho closed this as completed Apr 2, 2016
@antoineol
Copy link

Works like a charm, I can install from cmd and enter credentials. Thanks a lot @dscho !

@blowsie
Copy link

blowsie commented Apr 7, 2016

What I would suggest to anyone reading this;

Generally this issue comes from package installers (like npm) not prompting the user for credentials.
One excellent solution to this is using SSH, that way it can simply just authenticate without needing to prompt for credentials.

@blowsie
Copy link

blowsie commented Apr 7, 2016

Referencing:
npm/npm#8636 (comment)

@antoineol
Copy link

@blowsie I think the issue here was related to git for Windows, because we could reproduce it with git clone https://some-repo-with-credentials in a cmd (no issue in git bash). The exact same error was reported with npm, bower... And the solutions/workarounds to avoid the git credentials issue also solved it for npm/bower/jspm...

I am not sure it is exactly the same issue as the link you provided. This one seems to be an extra npm-specific issue (I was lucky and didn't face it - any relation with being using npm 3.x instead of 2.x?).

+1 for SSH, it will also help to automate builds.

@nmz787
Copy link

nmz787 commented Mar 18, 2020

this still happens with the latest install of Git For Windows... and I cannot use GUI credential input, as I'm using Git in a scripted manner, programmatically detecting the username and password prompts, and injecting them as they're requested.

In fact, I'm specifically running this when I setup my Continuous Integration hosts (where my automation is running):
git credential-manager uninstall --force

@nmz787
Copy link

nmz787 commented Mar 18, 2020

here's another conversation complaining about this impacting automation: https://github.521000.bestmunity/t5/GitHub-Actions/Is-it-possible-to-disable-the-Windows-git-credential-helper/td-p/33962

@dscho
Copy link
Member

dscho commented Mar 19, 2020

Wait, this ticket is about interactive prompts, why are we talking about scripted use now?

If you truly want to disable any credential helper, you'll have to call git -c credential.helper= <command> [...]

@nmz787
Copy link

nmz787 commented Mar 19, 2020

Yes, I wrote automation around my continuous integration which performs pip installs from web hosted git repos, and that's where interactive credential checks come up. I use wexpect for performing the terminal automation.

@dscho
Copy link
Member

dscho commented Mar 19, 2020

That sounds like it dearly wants to be simplified via a custom credential helper.

@ManyAngledOne
Copy link

I am also having this issue after installing git through conda (on windows) and attempting to clone a repo within an anaconda prompt.

@cowlinator
Copy link

cowlinator commented Dec 7, 2024

Just experienced this with git version 2.47.1.windows.1.

My workaround:

  • uninstall git,
  • re-install git via chocolatey (from cmd): powershell Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) && %ProgramData%\chocolatey\bin\RefreshEnv.cmd && choco install -y git && choco install -y git-lfs %ProgramData%\chocolatey\bin\RefreshEnv.cmd
  • git config --global credential.helper cache --timeout=86400
  • git config --global credential.githubauthmodes pat

Now it should only prompt you for username and personal access token on the cmd line.

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

No branches or pull requests

7 participants