r-lib / credentials

Tools for Managing SSH and Git Credentials
https://docs.ropensci.org/credentials
Other
72 stars 5 forks source link

terminal prompts disabled #24

Closed stefvanbuuren closed 2 years ago

stefvanbuuren commented 2 years ago

Trying to update GITHUB_PAT using credentials 1.3.2, but I am getting curious behaviour.

> library(credentials)
Found git version 2.24.0
Supported HTTPS credential helpers: cache, store
Found OpenSSH_8.6p1, LibreSSL 3.3.6
Default SSH key: /Users/{user}/.ssh/id_rsa
> git_credential_ask()
$protocol
[1] "https"

$host
[1] "github.com"

$username
[1] "..."

$password
[1] "ghp_......."

attr(,"class")
[1] "git_credential"
> git_credential_update()
error: cannot run rpostback-askpass: No such file or directory
fatal: could not read Username for 'https://github.com': terminal prompts disabled
Error: Failed to call 'git credential fill'
> git_credential_ask()
error: cannot run rpostback-askpass: No such file or directory
fatal: could not read Username for 'https://github.com': terminal prompts disabled
Error: Failed to call 'git credential fill'
> set_github_pat()
If prompted for GitHub credentials, enter your PAT in the password field
/Users/{user}/Library/R/x86_64/4.2/library/credentials/ask_token.sh: line 3: exec: rpostback-askpass: not found
error: unable to read askpass response from '/Users/{user}/Library/R/x86_64/4.2/library/credentials/ask_token.sh'
fatal: could not read Password for 'https://PersonalAccessToken@github.com': terminal prompts disabled
Error: Failed to call 'git credential fill'

The first time git_credential_ask() asks for my local user password to unlock osxkeychain, and produces the expected result.

I tried the first two solutions in https://stackoverflow.com/questions/32232655/go-get-results-in-terminal-prompts-disabled-error-for-github-private-repo, but no luck. Happens on two different macs, both running OSX 12.6.

Appreciate any ideas that could help.

stefvanbuuren commented 2 years ago

Apparently, I switched to SSH instead of HTTPS authentication when trying the following stackoverflow solution:

git config --global --add url."git@github.com:".insteadOf "https://github.com/"

Now I need to find a way to go back.

stefvanbuuren commented 2 years ago

Delete from .gitconfig the following lines:

[url "git@github.com:"]
    insteadOf = https://github.com/

and check that git remote -v now again gives HTTPS style URLs.