带有RCurl的sftp协议-最后一步,如何将R到libcurl的R路径从usr/lib更改为usr/local/lib [英] sftp protocol with RCurl - last step, how to change R path to libcurl from usr/lib to usr/local/lib

查看:83
本文介绍了带有RCurl的sftp协议-最后一步,如何将R到libcurl的R路径从usr/lib更改为usr/local/lib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先-我知道这不是特定的代码问题,请随时投票解决问题,但是我今天半天大部分时间都在努力解决此问题,并且可以寻求帮助.我也认为该线程可以帮助任何试图使R中的sftp协议工作的人,因为我将分享我今天所做的事情.

First off - I know this isn't a specific code problem, so feel free to vote to close the question, but I've spent the better part of half of my day today struggling with this problem and could use some help. I also think this thread can help anybody trying to get sftp protocol working in R, since I'll share what I've done today.

我一直在尝试更新RCurl,因此它支持sftp协议.在R中,我的协议看起来像这样(以及版本和主机):

I have been attempting to update RCurl so it supports sftp protocol. In R, my protocols look as such (with version and host as well):

> library(RCurl)
> curlVersion()$protocols
 [1] "dict"   "file"   "ftp"    "ftps"   "gopher" "http"   "https"  "imap"   "imaps"  "ldap"   "ldaps"  "pop3"   "pop3s"  "rtsp"   "smb"    "smbs"  
[17] "smtp"   "smtps"  "telnet" "tftp" 

> curlVersion()$version
[1] "7.43.0"

> curlVersion()$host
[1] "x86_64-apple-darwin15.0"

不好-没有sftp选项...

Not great - no sftp option...

我关注了此线程- http://andrewberls.com/blog/post/adding-sftp-support-to-curl -更新我机器上的curl,并且在此方面取得了部分成功.当我在命令行中运行以下命令时,就会反映出成功的部分:

I followed this thread - http://andrewberls.com/blog/post/adding-sftp-support-to-curl - to update curl on my machine, and was partially successful in doing so. The success part is reflected in when I run the following in the command line:

curl -V 
curl 7.55.1 (x86_64-apple-darwin15.6.0) libcurl/7.55.1 zlib/1.2.5 
libssh2/1.8.0
Release-Date: 2017-08-14
Protocols: dict file ftp gopher http imap ldap ldaps pop3 rtsp scp sftp smtp telnet tftp 
Features: AsynchDNS IPv6 Largefile libz UnixSockets 

这很好,因为我已经更新了curl.但是,当我加载RCurl并在R中运行curlVersion()时,它没有更新.我已经检查了/usr/目录的lib文件夹,并遇到以下问题.我的/usr/lib和/usr/local/lib中都存在libcurl文件.具体来说:

This is great, because I've got curl updated. However, when I load RCurl and run curlVersion() in R, it's not updated. I've examined the lib folders of my /usr/ directory and have the following problem. In both my /usr/lib AND /usr/local/lib, there exists libcurl files. Specifically:

    /li/lib中的
  • libcurl.3.dylib,libcurl.4.dylib和libcurl.dylib
  • 在/usr/local/lib中的
  • libcurl.4.dylib,libcurl.dylib,libcurl.a和libcurl.la
  • libcurl.3.dylib, libcurl.4.dylib, and libcurl.dylib in /usr/lib
  • libcurl.4.dylib, libcurl.dylib, libcurl.a and libcurl.la in /usr/local/lib

我的/usr/local/lib目录中的文件是我要使用的新文件,但这是我头疼的地方.我将四个文件从/usr/local/lib复制到/usr/lib中,然后我破坏了计算机.我的许多应用程序都停止了加载,并且由于担心搞砸其他事情,我不得不重新安装OSX.当我重新安装OS X时,它会将我的文件放回各自的文件夹(它们在上面的项目符号中的显示方式).

The files in my /usr/local/lib directory are the new files that I'd like used, however here is where my major headache began. I copied the four files from /usr/local/lib into /usr/lib and I BROKE MY COMPUTER. Many of my applications stopped loading, and I had to reinstall my OS X on account of being afraid of messing anything else up. When I reinstalled my OS X, it put my files back into their respective folders (how they look in the bullets above).

如果我不得不猜测,我可能不应该移动.a或.la文件...我不确定.

If I had to guess, I probably shouldn't have moved the .a or .la files... I'm not sure.

最后一件事-当我在控制台中运行$ $ PATH时,我得到:

One last thing - when i run $ $PATH in console, I get:

$PATH
-bash: /Users/Home/.rvm/gems/ruby-2.3.3/bin:/Users/Home/.rvm/gems/ruby-2.3.3@global/bin:/Users/Home/.rvm/rubies/ruby-2.3.3/bin:/Users/Home/anaconda2/bin:/usr/local/git/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/TeX/texbin:/Users/Home/.rvm/bin: No such file or directory

/usr/local/bin在/usr/bin之前.但我看不到/usr/local/lib或/usr/lib的任何内容-我可以在我的路径中添加这些(/usr/local/lib)来解决此问题吗?R中的.libPaths()给了我这个:

/usr/local/bin is before /usr/bin. but I don't see anything with /usr/local/lib or /usr/lib - could I add these (/usr/local/lib) to my path to fix this? .libPaths() in R gives me this:

.libPaths()
"/Library/Frameworks/R.framework/Versions/3.4/Resources/library"

...如果有帮助的话

...if it helps at all

编辑-我应该注意,所有问题的根源在于,由于R的curlVersion()$ protocols中未列出"sftp",因此当我运行RCurl :: getURL()或RCurl ::时ftpUpload()(我希望使用ftpUpload),因为两者我都收到错误:

EDIT - I should note that the root of all problems, ofcourse, is that since 'sftp' is not listed in curlVersion()$protocols in R, that when i run RCurl::getURL(), or RCurl::ftpUpload() (im hoping to use ftpUpload), for both I receive the error:

> RCurl::ftpUpload(what = 'myfile.txt', to = 'sftp://userid:userpw@ip/'myfile.txt')
Error in function (type, msg, asError = TRUE)  : 
  Protocol "sftp" not supported or disabled in libcurl

谢谢!

推荐答案

从源代码安装RCurl对我来说有用!

Installing RCurl from source did the trick for me !

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

我在这里找到了解决方案- http://www.omegahat.net/RCurl/FAQ.html -具体来说,以下几行.

I found the solution here - http://www.omegahat.net/RCurl/FAQ.html - specifically, the following lines.

我无法在RCurl中使用scp或sftp,但是curl的文档似乎表明它可以.所以为什么RCurl不支持它?

"I can't use scp or sftp within RCurl but the documentation for curl seems to suggest that it can. So why does RCurl not support it?

RCurl确实支持它,但是可能的问题是您所安装的libcurl版本不支持它.您可以通过curlVersion命令检查libcurl以及RCurl支持哪些协议.如果不存在scp和sftp,请重新安装libcurl,但要使用libssh2进行支持.在安装libcurl之前,您将需要安装libssh2开发库和头文件.在某些操作系统上,您将需要从源代码重建RCurl."

RCurl does support it, but the likely problem is that the version of libcurl you have installed does not support it. You can check what protocols your libcurl and hence RCurl supports via the command curlVersion. If scp and sftp are not there, reinstall libcurl but with support using libssh2. You will need to have the libssh2 development libraries and headers installed before installing libcurl. On some OSes, you will need to rebuild RCurl from source."

总的来说,这是我的问题从始至终的一个很好的总结.如果您的RCurl版本不支持sftp,则需要首先安装(在命令行上)libssh2,然后重新安装libcurl,然后出于某种原因从源代码进行重建.

In general, this is a great summary of my issue from start to finish. If your version of RCurl doesn't support sftp, you need to install (at the command line) libssh2 first, then reinstall libcurl, then rebuild from source for some reason.

这篇关于带有RCurl的sftp协议-最后一步,如何将R到libcurl的R路径从usr/lib更改为usr/local/lib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆