I am trying to use the RCurl library to access an SFTP site to download files on a MacOS running Monterrey v12.4. As has happened to others, when RCurl calls the curl libraries SFTP is not enabled.
Following SFTP Support for curl on OSX I installed curl with openssl using homebrew. I uninstalled the curl and Rcurl libraries in RStudio.
In a terminal window, running 'curl -v' shows that sftp is available. In RStudio, running "system('which curl')" shows sftp is available.
However, when I try to retrieve a file via SFTP using the RCurl library, I receive the message:
Error in function (type, msg, asError = TRUE) :
Protocol "sftp" not supported or disabled in libcurl
I thought maybe the PATH was not set correctly. I added the following line to my .Renviron file.
PATH=/opt/homebrew/opt/curl/bin:$PATH
At this stage, it's not clear to me why sftp is not supported when trying to access a file on an SFTP site when using the RCurl library.
What else can I do to try to diagnose why this is occurring?
I found a solution. In the post SFTP Support for curl on OSX
there is code to enable SFTP support in curl on MacOS.
I ran the three lines:
PATH <- Sys.getenv("PATH")
version <- '7.86.0'
Sys.setenv(PATH = paste0("/opt/homebrew/Cellar/curl/", version, "/bin:", PATH))
and SFTP is enabled in RCurl.
an "echo $PATH" run from the terminal shows "/opt/homebrew/opt/curl/bin" in the path. I assumed this meant the OpenSSL enabled curl was being used, but that is not the case. Apparently the R PATH is different than the MacOS PATH.
My next step is to add this line to my .Rprofile file so that it is included each time I start R.