Giter VIP home page Giter VIP logo

Comments (36)

cmartin avatar cmartin commented on July 21, 2024 40

This also happened to me today. Newly updated RStudio and fresh install of git from git-scm.com after a macOS Sierra update.

I was also stumped by the RStudio git binary picker which looked correct at /usr/bin/git, but my actual git installation was at /usr/local/bin/git (as found with the which git command). Once I pointed RStudio to the correct git binary location, everything reappeared.

Hopefully this will be useful to others as well, this issue is in the top google results for "RStudio wont detect git"

from happy-git-with-r.

joebowness avatar joebowness commented on July 21, 2024 17

My fix to this problem was to change the Git executable path in RStudio > Preferences > Git/Svn from /usr/bin/git to /usr/local/bin/git and then restart RStudio.

from happy-git-with-r.

 avatar commented on July 21, 2024 10

Same problem. Solved it twice using two different methods:

  1. By using /usr/local/git/bin/git. For some reason /usr/local/bin/git (mentioned by @joebowness ) is just a shortcut to /usr/local/git/bin/git, and usr/bin/git, despite pointing to what appears to be a git executable, doesn't work at all (without xcode, see 2).
  2. By installing xcode and confirming with username and password. In this case usr/bin/git is the the exec being used by rstudio.

Is it odd that there are multiple git execs in subdirectories of the same directory? One of them, /usr/local/git/bin/git, the one that works without xcode, was created precisely one year ago and is thus older than the other, usr/bin/git, which was created in July and only works with xcode.

from happy-git-with-r.

 avatar commented on July 21, 2024 10

You're right. I just uninstalled Xcode (which is actually almost 11 GB). The git pane in Rstudio disappeared. Then I installed the command line tools using xcode-select --install, restarted R and… voilá! Everything seems to be working now. Thanks!

from happy-git-with-r.

nickreich avatar nickreich commented on July 21, 2024 6

I had this same problem even after installing XCode and the command line tools. It was fixed after I ran a simple command in the terminal like git config --global --list which then forced me to agree to the XCode license agreement. Then, restarted RStudio and it recognized that git was on my system.

from happy-git-with-r.

kevinushey avatar kevinushey commented on July 21, 2024 5

@cmartin, if you just updated to macOS Sierra, then likely one of the side effects of that was that the command line tools were uninstalled. What happens if you try to run

/usr/bin/git --version
/usr/bin/clang --version

from the terminal? If I'm correct, you should get a dialog asking you to reinstall command line tools -- please let us know if that was the case!

from happy-git-with-r.

jennybc avatar jennybc commented on July 21, 2024 3

Troubleshooting tips from @kevinushey:

Check Sys.which("git") in addition to which git. Record what both return.

Inspect .gitconfig. Is there anything strange / surprising? E.g. in the project where git isn't working:

   git config --global --list
   git config --system --list
   git config --local --list

Note that, if current project is NOT already a git repo, git config --local won't work for obvious reasons.

Are there any git-related errors in the logs? (Help -> Diagnostics ->
Show Log Files; there should be a file 'rsession-.log'; if
there was something emitted it should show up near the end of that
logfile)

Is it possible that the associated git config files have permissions
that disallow RStudio from reading them?

from happy-git-with-r.

jennybc avatar jennybc commented on July 21, 2024 3

We could navigate to this screen but the only entry in the Version control system dropdown was "(None)".

We simply had no access to Git functionality at all. For example, when creating a new repo de novo, there was no check box to make it a Git repo.

from happy-git-with-r.

jmuhlenkamp avatar jmuhlenkamp commented on July 21, 2024 3

All I did was xcode-select --install and then re-opened my Rstudio Projects and they were all fixed (i.e. git pane was appearing again).

UPDATE Dec 6, 2018: Issue came up for me again after installing macOS Mojave (10.14.1). This time I did 2 things to resolve it.

xcode-select --install
sudo xcode-select -switch /Library/Developer/CommandLineTools

For more information see Stack Overflow question here

from happy-git-with-r.

mcsiple avatar mcsiple commented on July 21, 2024 2

I had this same problem and managed to fix with the following steps (using MacOS Sierra, 10.12.6):

  • check global git repo ( git config --global --list )
  • navigate to project repo using Terminal
  • at this point I edited one of the files and pushed to the project repo, to test whether git was working w/o RStudio, but I don't think this was a necessary step
  • run
    git init
  • close and reopen the project in RStudio
  • Git tab reappears

from happy-git-with-r.

jennybc avatar jennybc commented on July 21, 2024 2

I recommend installing just the Xcode command line tools:

http://happygitwithr.com/install-git.html#mac-os

Based on your 6 GB comment, I wonder if we're miscommunicating and you installed Xcode in its entirety ... although I admit I don't know the size of Xcode command line tools. In that same section are ways to install Git that are more surgical, but not as easy.

from happy-git-with-r.

kevinushey avatar kevinushey commented on July 21, 2024 1

It looks like RStudio does provide some UI for initializing a Git repository in a project -- within Tools -> Project Options, there should be an option for enabling Git, e.g.

screen shot 2016-06-15 at 10 39 31 pm

Was this dialog available in each case?

from happy-git-with-r.

kevinushey avatar kevinushey commented on July 21, 2024 1

There have been a couple Xcode updates released recently, so I expect users will be bumping into this again. We're planning to report this state more clearly in the IDE:

rstudio/rstudio#5494

but that won't become part of an official RStudio release for a little while yet.

Until then, executing:

sudo xcode-select --install
/usr/bin/git --version

in a terminal should be sufficient to see whether Apple wants you to agree to the Xcode license or install command line tools.

from happy-git-with-r.

jennybc avatar jennybc commented on July 21, 2024

More from @kevinushey:

Try moving the /usr/local/bin/git (a symlink) out of the way. Doe that help? Does OS X
fall back to a default version of git?

not sure if that was tried or how it panned out @ttimbers?

from happy-git-with-r.

kevinushey avatar kevinushey commented on July 21, 2024

I should also double check -- has the git repository actually been initialized for that directory (has git init been called)? Does the .git directory exist in those projects?

I think that, if a git executable is detected / set, then the option to create new R projects with git initialized is provided, e.g.

screen shot 2016-06-15 at 10 32 00 pm

If the Create a git repository is not checked, then git init is not run as part of the project creation process, and then RStudio won't detect that the project is managed by git and hence won't show the Git pane.

FWIW, I did try using the version of git provided at https://git-scm.com/downloads and all seemed well.

from happy-git-with-r.

kevinushey avatar kevinushey commented on July 21, 2024

Looking a bit into the details of the source code, when deciding whether to show Git-related GUI, it checks:

  1. Is VCS enabled? (this should be set in the Git/SVN tab of Global Options; given that the path to the Git executable is being set I believe this should be the case),
  2. Can we successfully run git --version? That's used as the canary as to whether git can actually be used for that project.

We also have some special handling for Mavericks -- from comments in the source code, it sounds like Apple installed a 'dummy' version of git into /usr/bin/git, and one needs to install OS X developer tools to get the 'real' version of git.

I wonder if Mike and Natalia are able to run /usr/bin/git --version successfully? Maybe RStudio is inadvertently trying to use the version of git at /usr/bin/git, but that is failing for some reason (e.g. missing developer tools, borked system git installation for other reasons)?

Note that these checks are done on RStudio startup, before the R process is initialized, and so they would likely see the default binary path /usr/bin before e.g. /usr/local/bin.

from happy-git-with-r.

ttimbers avatar ttimbers commented on July 21, 2024

@jennybc @kevinushey we did not get the chance to try to move the /usr/local/bin/git (a symlink) out of the way, but we did try adding the "true" git to the $PATH and then pointing RStudio there. That did not help.

from happy-git-with-r.

ttimbers avatar ttimbers commented on July 21, 2024

@kevinushey yes, VCS was enabled on both of these machines via the Git/SVN tab of Global Options, and we also set the path to the Git executable in that tab.

Although we did not test git --version, git did work from the command line and a git client (Git Kraken) on both machines.

I will see Mike on Tuesday and see what happens when we try /usr/bin/git --version. But maybe what we need to recommend is that they install OS X developer tools to get the 'real' version of git.

from happy-git-with-r.

jennybc avatar jennybc commented on July 21, 2024

VCS was enabled on both of these machines via the Git/SVN tab of Global Options, and we also set the path to the Git executable in that tab

Just to elaborate: we were able to set the path enough for RStudio to accept it and for it to persist when we left the dialogue box and came back. So RStudio acknowledged this git executable in some narrow sense. But the IDE never changes, i.e. no Git pane ever appears. And we get an actual error whenever we do anything that would cause RStudio to call Git. It's like we get past whatever logic governs this interface. But then this path is being overridden or ignored at the moment of truth.

git did work from the command line and a git client (Git Kraken) on both machines.

Git Kraken calls libgit2, as GitUp does. So Git Kraken will work even in the complete absence of a functional local git installation. So the success from the command line is the real proof that we should be able to make RStudio do git things.

recommend is that they install OS X developer tools

Yeah I am definitely re-writing the instructions today.

from happy-git-with-r.

jennybc avatar jennybc commented on July 21, 2024

Thanks @nickreich! Helpful to have such reports.

from happy-git-with-r.

jennybc avatar jennybc commented on July 21, 2024

Isn't there also a need and some way to trigger re-accepting the Xcode CLT EULA or whatever? After an OS upgrade?

UPDATE: right, I see this is already mentioned much earlier in this thread.

from happy-git-with-r.

sandan avatar sandan commented on July 21, 2024

I was following this guide: http://r-pkgs.had.co.nz/git.html#git-init. I got stuck on the part after

In a shell, run git init. Restart RStudio and reopen your package.

I couldn't see the git pane right away. I had to go to View->Show Git

from happy-git-with-r.

jennybc avatar jennybc commented on July 21, 2024

@GershTri It's hard to say exactly how you got into this state. How did you install git one year ago? The simplest way I know to get Git working on Mac OS and with RStudio is definitely via Xcode command line tools. Which seems to be where you've ended up. And, yes, there have been combinations of Mac OS and RStudio versions where only the Xcode-managed version of Git would actually work (although I believe that is not the current situation).

from happy-git-with-r.

 avatar commented on July 21, 2024

I wasn't aware that git was already installed on macs, so I installed it myself. Usually apps recognize other versions of themselves during installation, which is why I'm a little perplexed by my labyrinthine usr/ directory. Installing Xcode is definitely the easiest method to get things working, but you end up with an app that you will probably never use parked on nearly 6 GB of valuable hard drive real estate. It seems like there should be a better way.

from happy-git-with-r.

sanity4sale avatar sanity4sale commented on July 21, 2024

Thank you so much, these instructions helped me reinstall Git for RStudio!!!

from happy-git-with-r.

jmuhlenkamp avatar jmuhlenkamp commented on July 21, 2024

+1, worked for me

from happy-git-with-r.

critgeog avatar critgeog commented on July 21, 2024

thank you all!

from happy-git-with-r.

jennybc avatar jennybc commented on July 21, 2024

For those of you helped by this thread ... is there one or two tips that constitute the "bottom line" and that should be incorporated into the instructions?

I'm having a hard time determining if there is an action item for me and would appreciate such a summary.

from happy-git-with-r.

critgeog avatar critgeog commented on July 21, 2024

I updated R, RStudio, and OS to HighSierra.

xcode-select --install . I launched it in the App Store, re-installed xcode (I think as a result of HighSierra). Then I agreed to terms in shell. Next, I restarted R, created a project, and was able to enter git info.

from happy-git-with-r.

harshmisra-1 avatar harshmisra-1 commented on July 21, 2024

I had this same problem even after installing XCode and the command line tools. It was fixed after I ran a simple command in the terminal like git config --global --list which then forced me to agree to the XCode license agreement. Then, restarted RStudio and it recognized that git was on my system.

@nickreich : AMazing Reply, that did help

from happy-git-with-r.

rupertoverall avatar rupertoverall commented on July 21, 2024

I had this same problem even after installing XCode and the command line tools. It was fixed after I ran a simple command in the terminal like git config --global --list which then forced me to agree to the XCode license agreement. Then, restarted RStudio and it recognized that git was on my system.

@nickreich : AMazing Reply, that did help

This worked for me too after RStudio suddenly stopped showing git tools. XCode is often updated in the background and breaks things like this silently.

from happy-git-with-r.

phsemple avatar phsemple commented on July 21, 2024

Same problem for me in 2020: Had to browse into /usr/bin/git and step back to /usr/local/bin/git for the git. The svm path was correct.

From CMartin in 2016: I was also stumped by the RStudio git binary picker which looked correct at /usr/bin/git, but my actual git installation was at /usr/local/bin/git (as found with the which git command). Once I pointed RStudio to the correct git binary location, everything reappeared.

from happy-git-with-r.

dkori avatar dkori commented on July 21, 2024

Same problem for me in 2020: Had to browse into /usr/bin/git and step back to /usr/local/bin/git for the git. The svm path was correct.

From CMartin in 2016: I was also stumped by the RStudio git binary picker which looked correct at /usr/bin/git, but my actual git installation was at /usr/local/bin/git (as found with the which git command). Once I pointed RStudio to the correct git binary location, everything reappeared.

Just had the same issue, git disappeared from Rstudio out of nowhere shortly after I successfully cloned a repo using Rstudio. Changing the path to the git installation from "usr/bin/git" to "usr/local/bin/git" as you described fixed it for me as well.

from happy-git-with-r.

letgenelhu avatar letgenelhu commented on July 21, 2024

xcode-select --install worked perfectly. I think maybe the macOS update triggered it.

from happy-git-with-r.

sanjmeh avatar sanjmeh commented on July 21, 2024

You're right. I just uninstalled Xcode (which is actually almost 11 GB). The git pane in Rstudio disappeared. Then I installed the command line tools using xcode-select --install, restarted R and… voilá! Everything seems to be working now. Thanks!

This looks to be a very long drawn solution. Is this the final and only solution? I am stuck with the same problem that rstudio does not detect git while if I go to a mac terminal or rstudio terminal pane we can execute git commands.

from happy-git-with-r.

jennybc avatar jennybc commented on July 21, 2024

@sanjmeh In one of the places where git works, do which git to reveal where the executable lives. Then tell RStudio about that path in Tools > Global options > Git/SVN. At least, that's a sketch of a solution.

from happy-git-with-r.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.