简体   繁体   中英

Setting path to git executable in RStudio under OSX Mountain Lion

I am running RStudio v. 0.97.237 under Mac OSX v. 10.8.2 (Mountain Lion). I am trying to set the path to my git executable file in RStudio. The correct path is /usr/local/git. There is a preference setting in RStudio for entering the path to the Git executable file (Preferences..., Git/SVN, Git executable). If I could simply type "/usr/local/git" into a dialog box, I expect I would be done.

However, RStudio will not allow me to simply type in the directory path. Instead, one is required to browse through the directory tree using the standard OSX browsing ("Choose file") utility. Following an upgrade of OSX from Snow Leopard to Mountain Lion, I find that many system-related directories, including /usr, are no longer visible in the OSX file browsing utility. They are visible in the shell (using XQuartz, command "ls"), but not in the Mountain Lion GUI. (Apparently Mountain Lion thinks it knows what is good for me.)

My questions:

1.) Is there a way in RStudio to set the path to the Git executable file directly, command-line style, without needing to use the OSX directory browsing utility?

2.) Alternatively, is there a way in OSX Mountain Lion to adjust System Preferences to make all directories and files visible, not just the restricted set visible using Mountain Lion's default settings?

3.) Is there some other means to resolve this problem?

Note: I had Git working properly with RStudio under OSX 10.6.8 (Snow Leopard). The problem arose after the upgrade to OSX 10.8.2.

Thank you for any suggestions.

I was able to find the answer to my question, courtesy of http://osxdaily.com/2009/02/25/show-hidden-files-in-os-x/ and http://support.rstudio.org/help/discussions/problems/2907-no-svn-in-mountain-lion .

To make sure you have the correct path to the Git executable file: open a terminal window, and type:

$ which git

In my case, the answer comes back: /usr/local/git/bin/git.

To make hidden files visible in Mountain Lion: Per osxdaily.com: "You can quickly show all hidden files in any Mac OS X save dialogue box by hitting Command+Shift+Period."

So: in RStudio, in the Git executable settings, click on 'Browse'; when the save dialog box opens, hit Command+Shift+Period. Navigate to the git executable file, select it, and Save.

I found that at least one repository still did not recognize the location of the new Git executable. I had to reset the use of Git as follows: Under 'Project Options...', switch the version control option from 'Git' to 'none'. Restart RStudio to make this change take effect. Then go back into the Project Options, switch the version control option from 'none' back to 'Git', and restart RStudio again.

This worked.

While it is true that Apple has always hidden the folders containing OS X's Unix underpinnings: /bin , /sbin , /usr (and now ~/Library since Lion), the article " 18 ways to view the ~/Library folder in Lion " should help here (in addition to Ctrl Shift . ).

The extreme solution is to make /usr visible again.
The normal solution is to make it visible only when you need it (Go To Folder, in the Finder's Go menu: Shift Command G ).

While searching for a way to let RStudio know my full PATH in system() calls under Mavericks (OSX10.9), I found the git path on my machine to exist and be as follows:

>cat /etc/paths.d/git
/usr/local/git/bin

If you do not have this file, create it with the git path fitting your own installation and your git executable should be found by RStudio. I hope this fix works on mountain lion as well, no way to test it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM