R 包从 GitHub 安装 - “'' 在当前工作目录中不存在
R packge install from GitHub - "'' does not exist in current working directory
我构建了一个新包,它托管在 GitHub 的 github.com/kevinwolz/hisafer。
我正在尝试通过 devtools::install_github() 安装程序包,但出现奇怪的错误。有帮助吗?
>install_github("kevinwolz/hisafer")
Downloading GitHub repo kevinwolz/hisafer@master
from URL https://api.github.com/repos/kevinwolz/hisafer/zipball/master
Installing hisafer
[这里5个包依赖(dplyr, tidyr, purrr, ggplot2, lubridate)自动安装成功,但我省略了文字]
"C:/Users/wolzkevi/DOCUME~1/R/R-34~1.3/bin/x64/R" --no-site-file --no-environ --no-save \
--no-restore --quiet CMD INSTALL \
"C:/Users/wolzkevi/AppData/Local/Temp/Rtmpg5OyD6/devtools28843ed4c0a/kevinwolz-hisafer-bf69883" \
--library="C:/Users/wolzkevi/Documents/R/R-3.4.3/library" --install-tests
* installing *source* package 'hisafer' ...
** R
** inst
** preparing package for lazy loading
Error : '' does not exist in current working directory ('C:/Users/wolzkevi/AppData/Local/Temp/Rtmpg5OyD6/devtools28843ed4c0a/kevinwolz-hisafer-bf69883').
Error : unable to load R code in package 'hisafer'
ERROR: lazy loading failed for package 'hisafer'
* removing 'C:/Users/wolzkevi/Documents/R/R-3.4.3/library/hisafer'
In R CMD INSTALL
Installation failed: Command failed (1)
看来这里的严重错误是"Error : '' does not exist in current working directory"。有谁知道为什么会这样?我的包裹 built/setup 的方式是否导致了问题?当我不从 GitHub 下载时,我可以从源代码安装包,所以这让我相信 GitHub 过程中发生了一些奇怪的事情。
SESSION 信息:
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252
[3] LC_MONETARY=French_France.1252 LC_NUMERIC=C
[5] LC_TIME=French_France.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] devtools_1.13.4
loaded via a namespace (and not attached):
[1] httr_1.3.1 compiler_3.4.3 R6_2.2.2 tools_3.4.3 withr_2.1.1 curl_3.1
[7] memoise_1.1.0 knitr_1.19 git2r_0.21.0 digest_0.6.15
问题是在 R/utils.R
中,您尝试从 inst/extdata
中读取不存在的文件(这是来自第 36 和 37 行):
INPUT.DEFS <- readr::read_delim(system.file("extdata", "input_defs.txt", package = "hisafer"), "\t", col_types = readr::cols())
OUTPUT.DEFS <- dplyr::arrange(readr::read_delim(system.file("extdata", "output_defs.txt", package = "hisafer"), "\t", col_types = readr::cols()), profile, name)
检查 inst/extdata
将显示 input_defs.txt
和 output_defs.txt
都不存在。
我是怎么想出来的?
我运行
devtools::load_all("hisafer/")
这也给出了错误
Error: '' does not exist in current working directory
但允许您显示信息回溯:
13.stop("'", path, "' does not exist", if (!is_absolute_path(path)) paste0(" in current working directory ('",
getwd(), "')"), ".", call. = FALSE)
12.check_path(path)
11.standardise_path(file)
10.read_delimited(file, tokenizer, col_names = col_names, col_types = col_types,
locale = locale, skip = skip, comment = comment, n_max = n_max,
guess_max = guess_max, progress = progress)
9.readr::read_delim(system.file("extdata", "input_defs.txt", package = "hisafer"),
"\t", col_types = readr::cols()) at utils.R#36
8.eval(exprs[i], envir)
7.eval(exprs[i], envir)
6.source_one(file, envir = envir)
5.source_many(paths, env)
4.force(code)
3.withr_with_dir(file.path(pkg$path), source_many(paths, env))
2.load_code(pkg)
1.devtools::load_all("hisafer/")
回溯中的第 9 条通知,它不仅显示了有问题的代码,而且还有助于显示它来自哪个文件以及它在哪一行。
问题根源:您的.gitignore
在你的.gitignore
中,你有行
inst/extdata/
inst/extdata/*
这意味着 inst/extdata/
中的所有文件和子文件夹都没有被跟踪,因此当用户尝试从 GitHub 安装时,他们没有获得他们需要的 extdata/
文件你的包才能正常工作。
附带说明一下,即使用户下载了您的存储库并手动添加 input_defs.txt
和 output_defs.txt
,他们也不会有您希望他们拥有的其他模板目录原因,因此构建小插图会导致安装错误。
我构建了一个新包,它托管在 GitHub 的 github.com/kevinwolz/hisafer。
我正在尝试通过 devtools::install_github() 安装程序包,但出现奇怪的错误。有帮助吗?
>install_github("kevinwolz/hisafer")
Downloading GitHub repo kevinwolz/hisafer@master
from URL https://api.github.com/repos/kevinwolz/hisafer/zipball/master
Installing hisafer
[这里5个包依赖(dplyr, tidyr, purrr, ggplot2, lubridate)自动安装成功,但我省略了文字]
"C:/Users/wolzkevi/DOCUME~1/R/R-34~1.3/bin/x64/R" --no-site-file --no-environ --no-save \
--no-restore --quiet CMD INSTALL \
"C:/Users/wolzkevi/AppData/Local/Temp/Rtmpg5OyD6/devtools28843ed4c0a/kevinwolz-hisafer-bf69883" \
--library="C:/Users/wolzkevi/Documents/R/R-3.4.3/library" --install-tests
* installing *source* package 'hisafer' ...
** R
** inst
** preparing package for lazy loading
Error : '' does not exist in current working directory ('C:/Users/wolzkevi/AppData/Local/Temp/Rtmpg5OyD6/devtools28843ed4c0a/kevinwolz-hisafer-bf69883').
Error : unable to load R code in package 'hisafer'
ERROR: lazy loading failed for package 'hisafer'
* removing 'C:/Users/wolzkevi/Documents/R/R-3.4.3/library/hisafer'
In R CMD INSTALL
Installation failed: Command failed (1)
看来这里的严重错误是"Error : '' does not exist in current working directory"。有谁知道为什么会这样?我的包裹 built/setup 的方式是否导致了问题?当我不从 GitHub 下载时,我可以从源代码安装包,所以这让我相信 GitHub 过程中发生了一些奇怪的事情。
SESSION 信息:
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252
[3] LC_MONETARY=French_France.1252 LC_NUMERIC=C
[5] LC_TIME=French_France.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] devtools_1.13.4
loaded via a namespace (and not attached):
[1] httr_1.3.1 compiler_3.4.3 R6_2.2.2 tools_3.4.3 withr_2.1.1 curl_3.1
[7] memoise_1.1.0 knitr_1.19 git2r_0.21.0 digest_0.6.15
问题是在 R/utils.R
中,您尝试从 inst/extdata
中读取不存在的文件(这是来自第 36 和 37 行):
INPUT.DEFS <- readr::read_delim(system.file("extdata", "input_defs.txt", package = "hisafer"), "\t", col_types = readr::cols())
OUTPUT.DEFS <- dplyr::arrange(readr::read_delim(system.file("extdata", "output_defs.txt", package = "hisafer"), "\t", col_types = readr::cols()), profile, name)
检查 inst/extdata
将显示 input_defs.txt
和 output_defs.txt
都不存在。
我是怎么想出来的?
我运行
devtools::load_all("hisafer/")
这也给出了错误
Error: '' does not exist in current working directory
但允许您显示信息回溯:
13.stop("'", path, "' does not exist", if (!is_absolute_path(path)) paste0(" in current working directory ('",
getwd(), "')"), ".", call. = FALSE)
12.check_path(path)
11.standardise_path(file)
10.read_delimited(file, tokenizer, col_names = col_names, col_types = col_types,
locale = locale, skip = skip, comment = comment, n_max = n_max,
guess_max = guess_max, progress = progress)
9.readr::read_delim(system.file("extdata", "input_defs.txt", package = "hisafer"),
"\t", col_types = readr::cols()) at utils.R#36
8.eval(exprs[i], envir)
7.eval(exprs[i], envir)
6.source_one(file, envir = envir)
5.source_many(paths, env)
4.force(code)
3.withr_with_dir(file.path(pkg$path), source_many(paths, env))
2.load_code(pkg)
1.devtools::load_all("hisafer/")
回溯中的第 9 条通知,它不仅显示了有问题的代码,而且还有助于显示它来自哪个文件以及它在哪一行。
问题根源:您的.gitignore
在你的.gitignore
中,你有行
inst/extdata/
inst/extdata/*
这意味着 inst/extdata/
中的所有文件和子文件夹都没有被跟踪,因此当用户尝试从 GitHub 安装时,他们没有获得他们需要的 extdata/
文件你的包才能正常工作。
附带说明一下,即使用户下载了您的存储库并手动添加 input_defs.txt
和 output_defs.txt
,他们也不会有您希望他们拥有的其他模板目录原因,因此构建小插图会导致安装错误。