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

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

Closed
LaughingBubba opened this issue May 6, 2017 · 20 comments · Fixed by #351
Closed

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

LaughingBubba opened this issue May 6, 2017 · 20 comments · Fixed by #351

Comments

@LaughingBubba
Copy link

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 laugingbubba@outlook.com
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
laughingbubba@outlook.com

Cheers

@loatheb
Copy link
Contributor

loatheb commented May 6, 2017

@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 git@github.com, 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}

@LaughingBubba
Copy link
Author

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

> ssh -T git@github.com
Permission denied (publickey).

@loatheb
Copy link
Contributor

loatheb commented May 6, 2017

@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

@rashid-softordi
Copy link

@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 "your-github@email.com"

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 git@github.com

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"

@gvikash16
Copy link

@rashid-softordi thanks above solution works like a charm

@michaeljota
Copy link

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

@renyajie
Copy link

renyajie commented Mar 3, 2018

@loatheb your solution works fine with me

@michaeljota
Copy link

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.

@Zhang21
Copy link

Zhang21 commented Mar 3, 2018

update to the lastest git version

@secsilm
Copy link

secsilm commented Mar 9, 2018

@Zhang21 your solution works fine with me

@JinChengneng
Copy link

@Zhang21 Thanks a lot.

@frontalnh
Copy link

frontalnh commented Mar 17, 2018

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

@parandurume
Copy link

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!

@agrass-GitHub
Copy link

agrass-GitHub commented Apr 18, 2018

@frontalnh This is useful.

deploy:
  type: git
  repo: git@github.com:agrass-GitHub/xxxx.git
  branch: master

@NicolasKun
Copy link

@frontalnh it's worked for me , thanks!

@pingfengafei
Copy link

@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!

@jiangliux
Copy link

@frontalnh thank u

@adititipnis
Copy link

This helped

Try adding this into your git config

[credential]
helper = wincred
or via console

git config --global credential.helper wincred

@ted423
Copy link

ted423 commented Jul 7, 2021

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

@XksA-me
Copy link

XksA-me commented Oct 27, 2021

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

malgcheong added a commit to malgcheong/malgcheong.github.io that referenced this issue Aug 9, 2024
Error: Spawn failed 발생
hexojs/hexo-deployer-git#71 에서 힌트 얻어서 수정
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.