Cannot run R from terminal after upgrading to macOS Sierra

偶尔善良 提交于 2019-12-12 04:22:59

问题


I recently updated my macbook to macOS Sierra (Version 10.12.3 (16D32)), and I am no longer able to run R directly from Terminal:

DN51ssqi:~ kjytay$ R
-bash: R: command not found
DN51ssqi:~ kjytay$ R --version
-bash: R: command not found

Opening R from the Applications folder or from RStudio works fine. Anyone experience this issue/has been able to fix it?

Here is my R version information:

platform       x86_64-apple-darwin13.4.0   
arch           x86_64                      
os             darwin13.4.0                
system         x86_64, darwin13.4.0        
status                                     
major          3                           
minor          3.2                         
year           2016                        
month          10                          
day            31                          
svn rev        71607                       
language       R                           
version.string R version 3.3.2 (2016-10-31)
nickname       Sincere Pumpkin Patch

回答1:


This is just a guess, but I'm thinking this is probably an issue with your PATH settings, which might have been overwritten when you upgraded*. Seems worth a try at least. This is from the RStudio support pages**:

R from source (including MacPorts and Homebrew)

When R is installed from CRAN on OS X the R executable is installed at /usr/bin/R. However, if R is installed directly from source or via a package manager like MacPorts or Homebrew, then the R executable is installed to either /usr/local/bin/R (Homebrew) or /opt/local/bin/R (MacPorts). In order to support these variations, RStudio scans for the R executable in the following sequence:

/usr/bin/R
/usr/local/bin/R
/opt/local/bin/R

If RStudio is not able to locate R by scanning these locations, it will fall back to using whatever version of R is located at /Library/Frameworks/R.framework/.

If RStudio is finding R OK, then you must have it at one of these locations. Make sure these locations are in your $PATH list:

In the Terminal:

echo $PATH

Will display your current PATHs list. If any of the locations in the RStudio quote are missing, you can see if that's where R is located by trying to specify that location. For example:

/usr/local/bin/R

If that works to start R, just add that location to your PATHs list:

export PATH=$PATH:/usr/local/bin

So that OSX knows where to find it!

* It's been noted elsewhere that homebrew breaks, for example, on upgrade to Sierra. Here's a blog post outlining some steps an R user might like to take after the upgrade: http://www.statsblogs.com/2017/01/26/upgrading-to-macos-sierra-nee-osx-for-r-users/

** Here's the support page where the quote is from https://support.rstudio.com/hc/en-us/articles/200486138-Using-Different-Versions-of-R



来源:https://stackoverflow.com/questions/41951145/cannot-run-r-from-terminal-after-upgrading-to-macos-sierra

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!