Errors when using RStudio's Git tools - r

When attempting to push to GitHub from RStudio, I get the following errors.
error: unable to read askpass response from 'rpostback-askpass'
fatal: could not read Username for 'https://github.com':
No such device or address
RStudio has my origin as
https://github.com/rmscriven/other.git
when it actually should be
https://github.com/rmscriven/saber.git
RStudio will not allow me to change the origin from the version control system. Here is what it shows:
Is it possible to change my GitHub origin url from RStudio?

Thanks to the pro tip provided by #krlmlr in the comments,
Use an empty target directory. Look for "clone URL" on your GitHub project page, perhaps choose the SSH variant.
I clicked "clone url" on GitHub once, nothing. Then again, nothing. And once again for good measure, nothing. So I went to the terminal, read the man git help file, and decided to change my password and reconfigure. These are the lines I ran, and it was successful.
git config --global user.name <myuser.name>
git config --global user.email <myuser.email>
git clone https://github.com/rmscriven/saber.git
git pull
Then I went to RStudio and it allowed me to clone my repository, and change the URL of my version control setting. Here's a colorful pic
New project -> Version Control -> Git -> Create Project
Next, magic happened, and I had a copy of my package which I very carefully removed to prepare to push the development tarball to GitHub. Rock on.
#krlmlr, I thank you for nudging me in the right direction. Now I feel like I'm actually doing it the right way. :)
And for fun, try saying 'rpostback-askpass' ten times fast.

I had the same problem and for me these two simple steps worked great:
Add the SSH key from RStudio to my github account.
Change the origin URL and use the -u flag for push/pull once (solution found here).
For 1., in RStudio go to Tools → Global Options... → Git/SVN → view public key, and copy the key. In your browser of choice, logged in on Github, click Edit Profile → SSH keys and paste the copied key here.
For 2., back in RStudio, click Tools → Shell… , then enter:
git remote add origin https://github.com/myname/test.git
git config remote.origin.url git#github.com:myname/test.git
git pull -u origin master
git push -u origin master
Of course, change "myname" to your username and "test.git" to the name of your project. (Or even "github.com" to the URL of your institute's github or similar.)
After doing this once, the Push/Pull buttons in RStudio should work and you don't need the shell anymore!

I've been running into this issue on multiple computers now, with a remote that doesn't support SSH and thus can't leverage password-less login.
The problem in this case is that by default, git ask for the password interactively, and RStudio can't display this graphically. The trick is to use git's credential storage system.
For instance on Mac OS X:
git config --global credential.helper osxkeychain
On Linux one could use the gnome-keyring integration.

Related

Receiving the following error when pushing commitments to Github in R: error: cannot run rpostback-askpass: No such file or directory fatal:

I want to push some changes to my GitHub repository and I receive the following error, which I have been trying to solve for the last couple of hours.
error: cannot run rpostback-askpass: No such file or directory
fatal: could not read Username for 'https://github.com': Device not configured
What I have just done is
Open a new repository on Github
Go to code and copy the https link
Go to R Studio > New Project > Version Control > Git
Paste the https link to repository URL
Write some code and save it to an R file
Select the file > Commit > and Push
and I receive this error, which I was not getting previously. (Note that I took a long break and during this time I have not committed anything to Github but previously, I have not face any error like that.)
I have searched some solution on the internet, while some suggested to use SSH key instead of https, I could not find a neat solution (that might be because I am not familiar with the Github workflow)
Therefore, I would appreciate if you can just provide me a clean solution on how to solve this problem. Thank you for your attention beforehand.
PS: I am using a Mac if that would matter.
This should be linked to the lack of credential helper which means Git is trying to read credentials from your terminal, since it exhausted other options.
Check your git config --global credential.helper first.
Try and install GCM, the Git Credential Manager (which is no longer GCM-core).
And reference it in your config:
git config credential.helper manager

Connecting RStudio Cloud to GitHub

Trying to connect GitHub account to RStudio cloud but when I try to commit a test script, even though I've told Git who I am, RStudio cloud still gives an error saying it doesn't know which email/username to use. Most information about how to connect them is specific to the downloaded version of RStudio, but I unfortunately need to use RStudio cloud.
Steps I took:
Download Git, make github account, create new repository called "testing"
Configure git using git bash with:
git config --global user.email "you#example.com"
git config --global user.name "your name"
Open a new project in Rstudio cloud (new project> new project from git repository), using link from repository called "testing"
Set up Git in RStudio (tools>global options>git/SVN). I wasn't sure what file path to put for the exe. Here's what I tried:
a. Leaving it as default (default is "/usr/bin/git")
b. linking it to the physical location of the exe on my computer (in my downloads)
c. uploading the exe to my cloud project folder, then putting that link in the box
All produced the same error (see below)
Create and copy SSH key to github repository "testing"
Create dummy script
Save (appears in the cloud folder)
Stage the dummy script and click commit in the git tab of the environment window
New window opens--top right has the option to put in a commit message. Tried with and without text there.
Press commit
Popup named "Git commit" says "Please tell me who you are. Run git config --global user.email "you#example.com"; git config--global user.name "your name" to set your account's default identity. Omit --global to set the identity only in this repository. Fatal: unable to auto-detect email address (got 'r1487703#application-7788368-deployment-16293362-lqv6m.(none)')
I tried putting those commands into the console just in case but it says "unexpected symbol in "git config"".
I also looked at this github post: and tried their suggestions but no dice. (ie "git remote -vv" just returns "unexpected symbol in "git remote"")
Thank you for any time you spend, I am extremely new to all programming and trying to learn through a course that is requiring me to do this.
You can see a similar case in this issue
In the RStudio Terminal (not the Console but the tab next to it --- the prompt should have a $ and not >), type
$ git config --list --show-origin
If you see nothing related to your GitHub user ID or email or the information is incorrect, continue to the next step.
One at a time, type
$ git config --global user.name "<username>"
$ git config --global user.email "<email#address.edu>"
replacing <username> with your GitHub ID or name and <email#address.edu> with your email, leaving the quotes in both cases
Type
$ git config --list --show-origin
again to confirm that information is now stored (it should print to the Terminal output).
Use Git to confirm it has worked.

cannot set up PAT authentication for git on linux server via rstudio

I have access to a Linux server at work where I code in RStudio. Recently, the pull/push buttons have been greyed out in the git pane, and I also haven't updated from basic password authentication which I know GitHub is deprecating soon. However, I can't get it to accept a PAT, and clearly this repository has gotten unlinked from GitHub somehow.
When I run git remote -v from the terminal, I see the correct repository and branches.
When I run gitcreds::gitcreds_set() from R, it shows my correct GH username, and that it has saved a password. It then gives me an option to replace the credentials, but when I put in a new PAT (shown below as XXXXXX), I get an error:
-> What would you like to do?
1: Keep these credentials
2: Replace these credentials
3: See the password / token
Selection: 2
-> Removing current credentials...
? Enter new password or token: XXXXXXXX
Error in new_git_error("git_error", args = args, stdout = out, status = attr(out, :
System git failed: error: unknown option `get-urlmatch'
usage: git config [options]
I tried googling this error but haven't come across anything useful. Thanks in advance for any ideas. I imagine that fixing the git connection will also fix the greyed-out push/pull buttons in RStudio.
The --get-urlmatch option to git config first appeared in Git version 1.8.5. While any modern Linux system will ship with a Git version of at least 2.0, there are a bunch of rather old systems that still come with Git 1.8 or even 1.7 variants.
There might be a way to work around this in RStudio, but your best bet is probably to get a newer Git version installed on the system. Git is generally pretty backwards-compatible although there were a few user-interface-default changes between 1.x and 2.0 (and there's another one coming up, though I doubt anyone will call this 3.0).

Rstudio greyed out Git commands and (No branch)

I am currently struggling with getting Rstudio to work with my git repositories. When I set up a new project and assign the git repository, the branch is set on Master and the commit, pull, and push buttons are all active. Everything works just fine. Then, at some point the branch is switched to (No Branch) and the commit, pull, and push buttons are greyed out (shown below). This happens to every single git project I make. Works at first then is greyed out.
I am still able to use git commands from Shell, but the GUI interface is not working.
I have spent some time looking through customer support forums and Googling the problem. One site that I found (https://www.r-bloggers.com/things-i-forget-pushpull-greyed-out-in-rstudio/) indicated that there is an issue with the configuration list. However, when I do git config --list, I find that I do have branch.master.remote=origin and branch.master.merge=refs/heads/master at the bottom of the configuration.
I also attempted a git push -u origin master, but that did not work either.
I use RStudio and github daily, and I would be so pleased if the GUI interface was working properly again.
I would be very grateful if someone could help me problem solve this issue.
EDIT: I am using OSX 10.9 Mavericks and Rstudio Version 0.99.903.
I had a similar problem with a repo I had already configured locally and pushed and pulled from/to it using CLI (although I didn't have the problem of being detached from a branch) and I solved it by doing the following:
Open your console and navigate to your repo
Make some commit
Make a push using -u (i.e. --set-upstream) flag, eg: git push origin master -u
Open Rstudio (or restart it if it was open while performing the previous step) and you'll see the push and pull icons are no longer greyed out.
Then, at some point the branch is switched to (No Branch) and the commit, pull, and push buttons are greyed out (shown below).
That is typical of a detached HEAD branch: see "Why did my Git repo enter a detached HEAD state?".
Revert to the command-line and check your git status.
You can easily recover from this by a checkout of a branch.
Or by forcing a branch to your current detached commit
git branch -f branch-name HEAD
git checkout branch-name
Then switch back to RStudio: all options should be available again.
As commented:
Tt turns out to be an RSA key issue.
The wrong key was in the Rstudio Config, which explains how Shell would work but not the Rstudio interface.
I just wanted to provide an update in case anyone in the future had a similar problem. While the answer provided earlier resulted in another temporary fix, I ultimately had to wipe my hard drive; reinstall the operating system; reinstall git, R, RStudio, and reconnect to my Github account before it would consistently work.
My solution may have been a bit overkill, but I have not had an issue with it since.
I had the same issue today and found this post. I am going to share how I solve it:
on terminal (Git) type the following:
$ git config --global user.name
(it should return your Github username)
if username isn't correct just type
$ git config --global user.name "correct_username"
then type
$ git config --global user.email
(it should return an email associated to your GitHub account)
I found a typo in my email and fixed it by typing
$ git config --global user.email "correct_email"
Then I added the origin (this you get it from GitHub)
$ git remote add origin https://github.com/my_username/my_repository.git
Then I setup the branch, most used ones are main and master, in my case it is main
$ git branch -M main
then I pushed from the terminal
$ git push -u origin main
after that my pull and push buttons are active.
I hope this can save some time for others.

Cannot implement git version control on R-Studio (Version Control System: NONE)

I'm trying to put a project under version control in R-Studio. I have installed git and everything is working from the git bash command-line. However, when I go to Tools >> Version Control in R-Studio, it says "None" under "Version Control System."
I have attached a screenshot here: http://i.imgur.com/Arc12GG.png
Does anybody know how to fix this?
Even after setting the path to the git executable on my Mac at "Macintosh HD/usr/bin", RStudio still showed "None" for the version control option. In Terminal, I entered "config git" and was greeted by the message that I had to agree to the new Xcode/iOS license. I was able to do that in Terminal by typing "sudo xcodebuild", entering my admin password, then scrolling to the end of the agreement text and entering "agree". Then git showed up as an option for version control. I mention this in case others are stymied even after setting the path to the git executable.
For Windows 10 users, even if you had git lovingly installed at:
C:/Program Files (x86)/Git/bin/git.exe
At some stage the update install moves it into your AppData directory. Thanks Redmond. (I think around Git 2.6.4)
TO FIX:
Make sure like #arvi1000 says above "Did you specify the path to the git executable in Global Options (not project options)? " - set path first in Global options in Rstudio under Tools
Change path under Git/SVN the Git Executable path from Program files to new location of git.exe now in Appdata. e.g. for my userprofile Info:
C:\Users[Your user profile "Info"]\AppData\Local\Programs\Git\bin
Now look in RStudio Project Options under Git/SVN to set Version Control System.
MORE HELP
See these answers in this thread for more and if you cannot find git.exe this is a helpful search tip.

Resources