hexo-deployer-git icon indicating copy to clipboard operation
hexo-deployer-git copied to clipboard

fatal: could not read Username for 'https://github.com': Invalid argument

Open LaughingBubba opened this issue 8 years ago • 20 comments

Hi I'm getting the above when I try to

hexo deploy

I'm not the only one to have this problem if you look at the latest comments in the Hexo trouble shooting guide

Indeed I am running on win10, however I suspect it's more likely there's a missing environment variable than not using the git cli.

Here's my repo

hexo deploy console log:

C:\Users\joseph\projects\LaughingBubba.github.io (master)
> hexo deploy
INFO  Deploying: git
INFO  Setting up Git deployment...
====> user name LaughingBubba email [email protected]
Initialized empty Git repository in C:/Users/joseph/projects/LaughingBubba.github.io/.deploy_git/.git/
[master (root-commit) 80def97] First commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 placeholder
INFO  Clearing .deploy_git folder...
INFO  Copying files from public folder...
INFO  Copying files from extend dirs..
...
blah ... multiple LF being replaced by CRLF warnings ... blah
...
bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.com': Invalid argument
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.com': Invalid argument

    at ChildProcess.<anonymous> (C:\Users\joseph\projects\LaughingBubba.github.io\node_modules\hexo-util\lib\spawn.js:37:17)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at ChildProcess.cp.emit (C:\Users\joseph\projects\LaughingBubba.github.io\node_modules\cross-spawn\lib\enoent.js:40:29)
    at maybeClose (internal/child_process.js:877:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
FATAL bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.com': Invalid argument

Error: bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.com': Invalid argument

    at ChildProcess.<anonymous> (C:\Users\joseph\projects\LaughingBubba.github.io\node_modules\hexo-util\lib\spawn.js:37:17)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at ChildProcess.cp.emit (C:\Users\joseph\projects\LaughingBubba.github.io\node_modules\cross-spawn\lib\enoent.js:40:29)
    at maybeClose (internal/child_process.js:877:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

NOTE: I deleted the .deploy_git folder and slipped in a console.log() in the local deployer set up function to make sure the user name was being parsed and I did make a typo.

I also made sure my global git user settings were right

C:\Users\joseph\projects\LaughingBubba.github.io (master)
> git config --global user.name
LaughingBubba

C:\Users\joseph\projects\LaughingBubba.github.io (master)
> git config --global user.email
[email protected]

Cheers

LaughingBubba avatar May 06 '17 04:05 LaughingBubba

@LaughingBubba I'm not sure. But I don't think it's the error with hexp-deployer-git, I think it's some reason with the git or repo. Try to do that:

  1. try to ping github with ssh -T [email protected], to see if you can really connect with it.

  2. try to change your repo remote into ssh

git remote -v

if the remote is https, change to use ssh.

git remote remove origin
git remote add origin ${your-ssh-repo-url}

revan-zhang avatar May 06 '17 09:05 revan-zhang

Hi @loatheb does this mean the ping worked???

> ssh -T [email protected]
Permission denied (publickey).

LaughingBubba avatar May 06 '17 16:05 LaughingBubba

@LaughingBubba No. That means you can't use git command to connect with github. Check your ssh public key to make the result like this. image

revan-zhang avatar May 06 '17 16:05 revan-zhang

@LaughingBubba

@tsupol # Issue is SOLVED! error: failed to execute prompt script (exit code 1) fatal: could not read Username for 'https://github.com': Invalid argument

1- Create a ssh key using Git Bash using following command

ssh-keygen -t rsa -b 4096 -C "[email protected]"

After running this command just install the by default options and enter the password balnk when it prompts.

2- Then run the following commands to locate the public/private key generated from step1

cd .ssh

cd ~/.ssh

3- Then run the following command to view your public:

cat id_rsa.pub

4- Copy your public key and go to your GitHub account -> settings -> create a SSH and GPG keys then click new ssh key and past your public key in the in key text field.

5- Verify your public key using Git Bash by running the following command:

ssh -vT [email protected]

You will get output like this

debug1: channel 0: free: client-session, nchannels 1 Transferred: sent 3848, received 2040 bytes, in 0.2 seconds Bytes per second: sent 16032.4, received 8499.5 debug1: Exit status 1

Then you no longer got "could not read Username for 'https://github.com': Invalid argument"

rashid-softordi avatar Jul 13 '17 13:07 rashid-softordi

@rashid-softordi thanks above solution works like a charm

gvikash16 avatar Oct 16 '17 20:10 gvikash16

How to make this work if my ssh key have a password?

michaeljota avatar Feb 24 '18 19:02 michaeljota

@loatheb your solution works fine with me

renyajie avatar Mar 03 '18 02:03 renyajie

BTW: if you have configured your ssh key with a password, and you are on windows, you have to run the command from the GIT Bash prompt.

michaeljota avatar Mar 03 '18 02:03 michaeljota

update to the lastest git version

Zhang21 avatar Mar 03 '18 02:03 Zhang21

@Zhang21 your solution works fine with me

secsilm avatar Mar 09 '18 06:03 secsilm

@Zhang21 Thanks a lot.

JinChengneng avatar Mar 13 '18 05:03 JinChengneng

I solved it by modifying '_config.yml' configuration

I tried all above but failed. then I found the configuration that hinders git to deploy by ssh

change remote origin from HTTP URL to ssh URL as noted above and additionally, fix the _config.yml file deploy information

deploy:
  type: git
  repo: {your ssh git repo}

it worked to me

frontalnh avatar Mar 17 '18 16:03 frontalnh

I could solve the same problem, I do appreciate your guide, @rashid-softordi , @loatheb ! Also @LaughingBubba , thanks to you, I could solve my problem. Without your question, I couldn't get the right answer!

parandurume avatar Apr 03 '18 13:04 parandurume

@frontalnh This is useful.

deploy:
  type: git
  repo: [email protected]:agrass-GitHub/xxxx.git
  branch: master

agrass-GitHub avatar Apr 18 '18 04:04 agrass-GitHub

@frontalnh it's worked for me , thanks!

NicolasKun avatar Oct 24 '18 09:10 NicolasKun

@Zhang21 thanks a lot. If someone else met this problem, plz check git version, I replace version 2.11.xx with 2.20.1, It's done!

pingfengafei avatar Dec 18 '18 07:12 pingfengafei

@frontalnh thank u

jiangliux avatar Jan 02 '19 12:01 jiangliux

This helped

Try adding this into your git config

[credential] helper = wincred or via console

git config --global credential.helper wincred

adititipnis avatar Mar 19 '19 11:03 adititipnis

For me , I met a network issue ,so I use socks5

ted423 avatar Jul 07 '21 16:07 ted423

Unexpectedly, after executing git init under the local project directory, my problem has been solved. I hope it will also be helpful to you.

XksA-me avatar Oct 27 '21 07:10 XksA-me