0

我已经陷入了一个兔子洞,试图设置 Github 操作来检查我的包的构建usethis::use_github_action_check_standard()。该函数在尝试从r-lib.yaml存储库中提取文件 时失败。我一直试图弄清楚为什么对我来说失败了。似乎对于来自 Github 的任何文件都失败了,但对于来自其他位置的文件确实有效。readLines()readLines()

##
## random .txt file works
##
readLines("https://filesamples.com/samples/document/txt/sample1.txt")
#> Warning in readLines("https://filesamples.com/samples/document/txt/
#> sample1.txt"): incomplete final line found on 'https://filesamples.com/samples/
#> document/txt/sample1.txt'
#> [1] "Utilitatis causa amicitia est quaesita."                                                                                                                                                                                                                                                                                                                   
#> [2] "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Collatio igitur ista te nihil iuvat. Honesta oratio, Socratica, Platonis etiam. Primum in nostrane potestate est, quid meminerimus? Duo Reges: constructio interrete. Quid, si etiam iucunda memoria est praeteritorum malorum? Si quidem, inquit, tollerem, sed relinquo. An nisi populari fama?"
#> [3] ""                                                                                                                                                                                                                                                                                                                                                          
#> [4] "Quamquam id quidem licebit iis existimare, qui legerint. Summum a vobis bonum voluptas dicitur. At hoc in eo M. Refert tamen, quo modo. Quid sequatur, quid repugnet, vident. Iam id ipsum absurdum, maximum malum neglegi."
#
##
## random .yaml file also works (very long, not showing output)
## 
# readLines("https://wg21.link/index.yaml")

##
## .yaml file from github does not work
##
readLines("https://raw.githubusercontent.com/r-lib/actions/master/examples/check-standard.yaml", encoding = "UTF-8")
#> Warning in file(con, "r"): InternetOpenUrl failed: 'A connection with the server
#> could not be established'
#> Error in file(con, "r"): cannot open the connection

##
## .txt file from github does not work
##
readLines("https://raw.githubusercontent.com/neslib/Neslib.Yaml/master/License.txt")
#> Warning in file(con, "r"): InternetOpenUrl failed: 'A connection with the server
#> could not be established'
#> Error in file(con, "r"): cannot open the connection

我尝试Use Internet Explorer library/proxy for HTTP在 RStudio 选项中选中和取消选中无效。

reprex 包于 2021-08-05 创建 (v2.0.0 )

4

1 回答 1

1

对于可能遇到此问题的其他任何人 - 我 Warning in file(con, "r"): InternetOpenUrl failed: 'A connection with the server could not be established'在启用 TLS 1.2 后丢失了警告:

  • Windows 菜单栏,单击工具 > Internet 选项 > 高级选项卡
  • 滚动到安全类别,手动选中使用 TLS 1.2 的选项框

在使用时遇到相同的错误集(如问题中的)后找到此解决方案download.file(),其中 Windows 的默认方法是 wininet.dll

于 2021-08-08T00:03:08.597 回答