R unable to load internet routines after upgrade to MacOS Sierra

723 views Asked by At

When running R after upgrading my mac to 10.12.6 (Sierra), R can no longer load libraries or access anything on the internet:

> install.packages("devtools")
--- Please select a CRAN mirror for use in this session ---
Warning: failed to download mirrors file (internet routines cannot be loaded); using local file '/anaconda/lib/R/doc/CRAN_mirrors.csv'

[...]

Warning: unable to access index for repository 
https://cran.cnr.berkeley.edu/src/contrib:

internet routines cannot be loaded
Warning messages:
1: In download.file(url, destfile = f, quiet = TRUE) : 
unable to load shared object '/anaconda/lib/R/modules//internet.so':
dlopen(/anaconda/lib/R/modules//internet.so, 6): Library not loaded: @rpath/libssh2.1.dylib
Referenced from: /anaconda/lib/R/modules//internet.so
Reason: image not found
2: package ‘devtools’ is not available (for R version 3.4.1) 

Similarly:

> source("https://bioconductor.org/biocLite.R")
Error in file(filename, "r", encoding = encoding) : 
  internet routines cannot be loaded
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
  unable to load shared object '/anaconda/lib/R/modules//internet.so':
  dlopen(/anaconda/lib/R/modules//internet.so, 6): Library not loaded: @rpath/libssh2.1.dylib
  Referenced from: /anaconda/lib/R/modules//internet.so
  Reason: image not found

This happens both when I run R from Terminal and when I run R from RStudio (though RStudio only gives me the error, not the warning, and then still fails).

I found other people with vaguely similar problems in the past; one common solution was to re-install XQuartz, which I have done, but which didn't help.

Another common solution was to update LD_LIBRARY_PATH. However, 'libssh2.1.dylib' does not seem to exist: 'locate libssh2.1.dylib' returns nothing. I did find libssh2.dylib in /Applications/Xcode.app/Contents/Developer/usr/lib/libssh2.dylib, which is presumably the same thing, but R isn't finding it, I suppose.

Any ideas? Thank you!

2

There are 2 answers

1
mfaulkner1989 On

EDIT: I found a simple solution. Just download the .tar file and use the command 'R CMD INSTALL mcmcse_1.3-2.tar', for example, in your terminal, from the directory in which your .tar file is saved.

I think that install.packages(‘package_name’) not working within R on macOS Sierra (with the package manager Anaconda installed) might be because Anaconda moves R’s path.


Just a reply to flag the same issue while using Anaconda 4.2.0 with R 3.4.1 on macOS Sierra 10.12.6. I was initially running R 3.4.0 in /usr/bin/R, but R has since become R 3.4.1 in /Users/[username]/anaconda/bin/R after installing Anaconda 4.2.0.

Warning: unable to access index for repository https://www.stats.bris.ac.uk/R/src/contrib:
  internet routines cannot be loaded
Warning messages:
1: In download.file(url, destfile = f, quiet = TRUE) :
  unable to load shared object '/Users/michaelfaulknerlocal/anaconda/lib/R/modules//internet.so':
  dlopen(/Users/michaelfaulknerlocal/anaconda/lib/R/modules//internet.so, 6): Library not loaded: @rpath/libssh2.1.dylib
  Referenced from: /Users/michaelfaulknerlocal/anaconda/lib/R/modules//internet.so
  Reason: image not found
2: package ‘mcmcse’ is not available (for R version 3.4.1)
1
Lucian On

This turns out to be, as far as I can tell, a bug in Anaconda2-4.4.0-MacOSX-x86_64.pkg I had an anaconda/ directory in /, /Applications/, and /Users/[me]/: I deleted all of them, and removed the Anaconda PATH change to .bash_profile. R then reverted to /usr/local/bin/R, which did not have the internet connection problems reported above. Then I reinstalled Anaconda from scratch, then installed RStudio from Anaconda-Navigator. 'which R' now pointed at /Users/[me]/anaconda/bin/R (the PATH having changed again upon install), and which had the internet connectivity problem. Running /usr/local/bin/R directly, even with Anaconda installed, had no problems.

I've filed the bug as https://github.com/Anaconda-Platform/support/issues/137 but now can at least run R myself by using /usr/local/bin/R.