I just posted the link to the GitHub repo with code for my time-series analysis posts. I had a little trouble operationalizing a github cloud repo on my Mac so I’m going to give you the play-by-play for how I did it, in case it helps anyone else out:

##############################################################
Problem Statement
I originally created the R studio project in this repository on my computer at work (a PC). This post from The Molecular Ecologist describes the steps I followed.

Before posting the link to the blog, I wanted to make some changes to some of the code. From my personal computer at home (which is a Mac Air running El Capitan) I:

  1. opened R studio
  2. File –>; New Project –>; Version Control –>; Git
  3. copied the url from github (https://github.com/aaronmams/cool-time-series-stuff.git) and pasted it as you see below to create a new R studio project on my Mac

Screen Shot 2016-01-29 at 2.45.17 PM.png

 

 

I made a few changes to the code and was able to commit those changes just fine (for illustrative purposes, a few screen shots are include below)

Screen Shot 2016-01-28 at 2.13.49 PM

Screen Shot 2016-01-28 at 2.15.37 PM

However, when I went to push those changes back to GitHub, shit went sideways. I got this error message:

error: unable to read askpass response from ‘rpostback-askpass’
fatal: could not read Username for ‘https://github.com’: Device not configured

Normally, when I follow these steps (clone a repository, make changes, commit changes, try to push changes back to the repo) on my PC, git/R studio prompts me for my github username and github password. On the Mac this did not happen so I figured I need some way to tell git what my credentials are so it would let me push changes from within R studio.
#########################################################

#########################################################
First Attempt
Word on the street was that this git credential issue might just be because I had an old version of git. I checked (using the Mac terminal):

$ git --version
$ git version 1.8.3.4 (Apple Git-47)

Ok, cool. I probably just need to upgrade git. I upgraded to git 2.6.4 but then, when I asked my computer what version of git I was on, it still told me I was on the old version. Turns out the factory install (I don’t know if it comes with Xcode or command line tools or what quite honestly) of git on osx is generally in /usr/bin, while the upgrade from homebrew gets dropped in /usr/local/bin. Thanks to this dude for the tip.

$ git --version
$ git version 1.8.3.4 (Apple Git-47)
$ export PATH=/usr/local/bin:$PATH
$ git --version
git version 2.6.4

So with my fresh install of git 2.6.4, I went back to R studio to see if this fixed my problem. Shockingly, it did not. After restarting R studio and opening a new R studio project from git, I still could not push any changes. The same error message appeared:

error: unable to read askpass response from ‘rpostback-askpass’
fatal: could not read Username for ‘https://github.com’: Device not configured

#########################################################

#########################################################
Second Attempt
After googling “github device not configured” I arrived at this page. These steps also did not fix my problem but I felt a little better knowing that git can now successfully attach my name and email address to changes made on projects from my computer…so I got that going for me, which is nice.

It wasn’t until I got to this page that I felt I was really getting somewhere. I set up the osxkeychain helper just like it says on the webpage…I’ll recap

$ git credential-osxkeychain
usage: git credential-osxkeychain <get|store|erase>

the ‘usage: git credential-osxkeychain ‘ part confirms that I have the keychain helper installed…if that doesn’t happen for you I’m not really sure what you should do…that shit’s above my paygrade…probably google it.

Next I had to put the helper in the same directory where git lives:

sudo mv git-credential-osxkeychain '/usr/local/bin/git-credential-osxkeychain'

Next, tell Git to use osxkeychain using the global credential.helper config:

git config --global credential.helper osxkeychain

So I got the keychain helper configured without setting my computer on fire….but there was no part of that process that prompted me for my git/github username or password so I was skeptical that the keychain helper configuration alone would solve my problem. I confirmed this by once again, restarting R studio, opening a project that had been pulled from one of my github repos, making some changes, trying to push those changes…same result:

error: unable to read askpass response from ‘rpostback-askpass’
fatal: could not read Username for ‘https://github.com&#8217;: Device not configured
#########################################################

#########################################################
Final Attempt

Here, apparently (courtesy of jennybc who appears to have some involvement in a class called “Statistical Methods for Higher Dimensional Biology at the University of British Columbia), is the crucial piece I was missing:

I needed to clone a repository once from the terminal and push it back to github, at which point I would be prompted for my git username and password.

$git clone https://github.com/aaronmams/cool-time-series-stuff
Cloning into 'cool-time-series-stuff'...
remote: Counting objects: 10, done.
remote: Total 10 (delta 0), reused 0 (delta 0), pack-reused 10
Unpacking objects: 100% (10/10), done.
Checking connectivity... done
$cd cool-time-series-stuff
$git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Username for 'https://github.com':
Password for 'https://aaron.mams@github.com': 

Everything up-to-date

After this initial clone-push through the terminal, all of my subsequent attempts to push changes in R studio have worked fine (fingers crossed).
#########################################################

Advertisements