是否可以使用devtools::install_git()从位于MS Windows上某个文件系统目录中的本地 git存储库安装软件包?
这些示例仅演示了如何从Web URL安装(例如install_git("git://github.com/hadley/stringr.git")).
从通过RStudio和devtools(CTRL + SHFT + L)加载的包中以及在git版本控制下(即子目录.git存在),我尝试了以下内容:
devtools::install_git(paste0("git://", getwd(), ".git"))
Run Code Online (Sandbox Code Playgroud)
该函数返回时出现此错误:
Downloading git repo git://C:/Users/Thyson/Documents/path/to/package/packagename.git
Error in git2r::clone(x$url, bundle, progress = FALSE) :
Error in 'git2r_clone': Malformed URL 'git://C:/Users/Thyson/Documents/path/to/package/packagename.git'
Run Code Online (Sandbox Code Playgroud)
所以我猜我刚刚得到文件系统URL错了?
为何使用devtools::install_git?你可以devtools::install改用.
library("devtools")
install()
Run Code Online (Sandbox Code Playgroud)
我之前在MS Windows中遇到过同样的问题并自己弄清楚了.例如,如果您有一个名为"C:\ path\to\pkga.git"的本地存储库.
devtools :: install_git( "C://path/to/pkga.git")
关键是在路径"C://path/to/pkga.git"中使用双斜杠.
希望适用于其他使用MS Windows.