Adding support for sftp to RCurl

While trying to download data from an FTP with the sftp protocol from R I encountered the folllowing error on my mac:

Error in function (type, msg, asError = TRUE)  : 
  Protocol "sftp" not supported or disabled in libcurl

The easiest way to fix this for me was performing the following steps:

brew install curl --with-libssh2

Then check whether sftp is now among the list of supported protocols:

/usr/local/opt/curl/bin/curl -V

Link to the new version of curl you installed:

brew link --force curl

Re-install RCurl from source:

install.packages("RCurl", type = "source")

And finally check if sftp is now supported:

RCurl::curlVersion()

1 comment:

Samuel Bosch said...

I no longer have access to a mac so it is difficult for me to comment on you issue. Your version of curl appears to support sftp but is clearly not the one used by RCurl. I would try again to re-install the RCurl package from source: install.packages("RCurl", type="source"). You can also explicitly set the path before installing RCurl: Sys.setenv(PATH=paste('/usr/local/opt/curl/bin', Sys.getenv('PATH'), sep=":")). See also this post with similar instructions https://mattdeboth.com/post/curl-mac-scp-sftp.html