在 OSX Mountain Lion 下的 RStudio 中设置 git 可执行文件的路径

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14011998/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 07:55:23  来源:igfitidea点击:

Setting path to git executable in RStudio under OSX Mountain Lion

gitosx-mountain-lionrstudio

提问by Arthur Small

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.

我在 Mac OSX v. 10.8.2 (Mountain Lion) 下运行 RStudio v. 0.97.237。我正在尝试在 RStudio 中设置我的 git 可执行文件的路径。正确的路径是/usr/local/git。RStudio 中有一个首选项设置,用于输入 Git 可执行文件的路径(首选项...、Git/SVN、Git 可执行文件)。如果我可以简单地在对话框中输入“/usr/local/git”,我希望我能完成。

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.)

但是,RStudio 不允许我简单地输入目录路径。相反,需要使用标准 OSX 浏览(“选择文件”)实用程序浏览目录树。在将 OSX 从 Snow Leopard 升级到 Mountain Lion 之后,我发现许多与系统相关的目录(包括 /usr)在 OSX 文件浏览实用程序中不再可见。它们在 shell 中可见(使用 XQuartz,命令“ls”),但在 Mountain Lion GUI 中不可见。(显然 Mountain Lion 认为它知道什么对我有好处。)

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?

1.) 在 RStudio 中有没有办法直接设置 Git 可执行文件的路径,命令行风格,而无需使用 OSX 目录浏览实用程序?

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

2.) 或者,在 OSX Mountain Lion 中有没有办法调整系统偏好设置,使所有目录和文件都可见,而不仅仅是使用 Mountain Lion 的默认设置可见的受限集?

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

3.) 有没有其他方法可以解决这个问题?

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.

注意:我让 Git 在 OSX 10.6.8 (Snow Leopard) 下与 RStudio 正常工作。升级到 OSX 10.8.2 后出现问题。

Thank you for any suggestions.

谢谢你的任何建议。

回答by Arthur Small

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.

我能够找到我的问题的答案,由http://osxdaily.com/2009/02/25/show-hidden-files-in-os-x/http://support.rstudio.org/ 提供帮助/讨论/问题/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:

要确保 Git 可执行文件的路径正确:打开终端窗口,然后键入:

$ which git

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

就我而言,答案又回来了:/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."

要在 Mountain Lion 中显示隐藏文件: Per osxdaily.com:“您可以通过按 Command+Shift+Period 快速显示任何 Mac OS X 保存对话框中的所有隐藏文件。”

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.

所以:在 RStudio 中,在 Git 可执行文件设置中,单击“浏览”;当保存对话框打开时,点击 Command+Shift+Period。导航到 git 可执行文件,选择它,然后保存。

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.

我发现至少有一个存储库仍然无法识别新 Git 可执行文件的位置。我必须按如下方式重置 Git 的使用:在“项目选项...”下,将版本控制选项从“Git”切换为“无”。重新启动 RStudio 以使此更改生效。然后返回到项目选项,将版本控制选项从“无”切换回“Git”,并再次重新启动 RStudio。

This worked.

这奏效了。

回答by VonC

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 CtrlShift.).

虽然 Apple 确实一直隐藏包含 OS X 的 Unix 基础的文件夹:/bin, /sbin, /usr(以及现在的 ~/Library 自 Lion 以来),文章“在 Lion 中查看 ~/Library 文件夹的 18 种方法”应该在这里有所帮助(此外到CtrlShift.)。

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

极端的解决方案是/usr再次可见。
正常的解决方案是仅在您需要时才使其可见(转到文件夹,在 Finder 的转到菜单中:)ShiftCommandG

回答by splaisan

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:

在寻找一种方法让 RStudio 在 Mavericks (OSX10.9) 下的 system() 调用中知道我的完整路径时,我发现我的机器上存在 git 路径,如下所示:

>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.

如果您没有此文件,请使用适合您自己安装的 git 路径创建它,您的 git 可执行文件应由 RStudio 找到。我希望此修复程序也适用于山狮,无法对其进行测试。