[英]Building my unaltered package suddenly fails: for Vignettes and 'arch = x64'
I've been developing a proprietary package (call it " my_pkg
") with vignettes, in RStudio with the latest version (4.1.1) of R. I'm working on a Lenovo ThinkPad with the following software我一直在使用最新版本(4.1.1)的 R 在 RStudio 中开发一个带有小插图的专有软件包(称为“
my_pkg
”)。我正在使用以下软件开发联想 ThinkPad
sysname release version machine
"Windows" "10 x64" "build 19043" "x86-64"
as provided by Sys.info()
.由
Sys.info()
提供。
Until recently, my devtools
workflow has been reasonably smooth (with one occasional exception ).直到最近,我的
devtools
工作流程还算顺利( 偶尔有一个例外)。 However, I've begun to encounter a very puzzling error, which occurs under conditions virtually identical to those beforehand, when the workflow proceeded without issue.但是,我开始遇到一个非常令人费解的错误,该错误发生在与之前几乎相同的条件下,当工作流程顺利进行时。
Despite the fact that my vignettes always built successfully before, and I have not edited them in the meantime, the build now fails for architecturally specific reasons...尽管我的小插曲以前总是成功构建的,而我同时没有编辑它们,但由于架构上的特定原因,现在构建失败了......
Error : package 'my_pkg' is not installed for 'arch = x64'
...when and only when I include the vignettes in the build. ...当且仅当我在构建中包含小插曲时。
I have reinstalled R (and Rtools and RStudio) from scratch, reinstalled devtools
(and its dependencies), and "rewound" my project to the last Git commit at which devtools::check()
succeeded.我从头开始重新安装了 R (以及 Rtools 和 RStudio),重新安装了
devtools
(及其依赖项),并将我的项目“倒回”到了devtools::check()
成功的最后一个 Git 提交。 I have also walked through extensive troubleshooting with responders like @SteffenMoritz and @Alexis , for whom I have appended further information in the section Info by Request .我还与@SteffenMoritz和@Alexis等响应者一起进行了广泛的故障排除,我在Info by Request部分中为他们附加了更多信息。
Unfortunately, nothing has worked.不幸的是,没有任何效果。
devtools::check()
devtools::check()
失败When I run devtools::check()
, everything starts promisingly...当我运行
devtools::check()
时,一切都开始有希望......
i Updating my_pkg documentation
i Loading my_pkg
Writing NAMESPACE
Writing NAMESPACE
-- Building --------------------------------------------------------------------------------- my_pkg --
Setting env vars:
* CFLAGS : -Wall -pedantic
* CXXFLAGS : -Wall -pedantic
* CXX11FLAGS: -Wall -pedantic
-------------------------------------------------------------------------------------------------------
√ checking for file 'C:\Users\greg\Workspace\R\Packages\my_pkg/DESCRIPTION' ...
- preparing 'my_pkg': (733ms)
√ checking DESCRIPTION meta-information ...
- installing the package to build vignettes
-----------------------------------
- installing *source* package 'my_pkg' ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
converting help for package 'my_pkg'
finding HTML links ... done
foo html
my_pkg-package html
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
...until the step testing if installed package can be loaded from temporary location
. ...直到步骤
testing if installed package can be loaded from temporary location
。 Here an error occurs:这里发生错误:
Error : package 'my_pkg' is not installed for 'arch = x64'
Error: loading failed
Execution halted
ERROR: loading failed
- removing 'C:/Users/greg/AppData/Local/Temp/RtmpSaabgx/Rinst332419517258/my_pkg'
-----------------------------------
ERROR: package installation failed
Error in (function (command = NULL, args = character(), error_on_status = TRUE, :
System command 'Rcmd.exe' failed, exit status: 1, stdout + stderr (last 10 lines):
E> ** building package indices
E> ** installing vignettes
E> ** testing if installed package can be loaded from temporary location
E> Error : package 'my_pkg' is not installed for 'arch = x64'
E> Error: loading failed
E> Execution halted
E> ERROR: loading failed
E> * removing 'C:/Users/greg/AppData/Local/Temp/RtmpSaabgx/Rinst332419517258/my_pkg'
E> -----------------------------------
E> ERROR: package installation failed
Type .Last.error.trace to see where the error occurred
The .Last.error.trace
suggests an issue with pkgbuild
specifically: .Last.error.trace
指出了pkgbuild
的一个问题:
> .Last.error.trace
Stack trace:
1. devtools::check()
2. withr::with_envvar(pkgbuild::compiler_flags(FALSE), action = "prefix", ...
3. base:::force(code)
4. pkgbuild::build(pkg$path, tempdir(), args = build_args, quiet = quiet, ...
5. withr::with_temp_libpaths(rcmd_build_tools(options$cmd, c(options$path, ...
6. base:::force(code)
7. pkgbuild:::rcmd_build_tools(options$cmd, c(options$path, options$args), ...
8. pkgbuild:::with_build_tools(callr::rcmd_safe(..., env = env, ...
9. withr::with_path(rtools_path(), code)
10. base:::force(code)
11. callr::rcmd_safe(..., env = env, spinner = FALSE, show = FALSE, ...
12. callr:::run_r(options)
13. base:::with(options, with_envvar(env, do.call(processx::run, ...
14. base:::with.default(options, with_envvar(env, do.call(processx::run, ...
15. base:::eval(substitute(expr), data, enclos = parent.frame())
16. base:::eval(substitute(expr), data, enclos = parent.frame())
17. callr:::with_envvar(env, do.call(processx::run, c(list(bin, args = real_cmdargs, ...
18. base:::force(code)
19. base:::do.call(processx::run, c(list(bin, args = real_cmdargs, ...
20. (function (command = NULL, args = character(), error_on_status = TRUE, ...
21. throw(new_process_error(res, call = sys.call(), echo = echo, ...
I have no clue as to why the architecture我不知道为什么架构
Error : package 'my_pkg' is not installed for 'arch = x64'
should be an issue only now .应该只是现在的问题。 There have been no substantive changes to my computer.
我的电脑没有实质性的变化。
Despite the message package installation failed
, and despite the fact that I've run devtools::
check()
rather than devtools::
install()
, the package acts as if it were "halfway" installed!尽管消息
package installation failed
,并且尽管我运行的是devtools::
check()
而不是devtools::
install()
,但该包的行为就好像它已经“中途”安装了一样! I can type my_p
in the console, and RStudio will autocomplete my_pkg
;我可以在控制台中输入
my_p
,RStudio 会自动完成my_pkg
; and I can then type my_pkg::
and RStudio will supply the standard autocompletion list of the functions in my_pkg
, which are all available.然后我可以键入
my_pkg::
并且 RStudio 将提供my_pkg
中所有可用的函数的标准自动完成列表。
However, typing my_pkg::
not only summons the @export
ed functions but also exposes my internal functions and data, as if I had typed my_pkg
:::
!但是,键入
my_pkg::
不仅会@export
ed 函数,还会公开我的内部函数和数据,就好像我键入my_pkg
:::
一样!
devtools::install()
or devtools::build(vignettes = FALSE)
devtools::install()
或devtools::build(vignettes = FALSE)
成功Oddly, when I actually run devtools::install()
, or comparably devtools::build_vignettes(vignettes = FALSE)
, the process completes without a hitch!奇怪的是,当我实际运行
devtools::install()
或类似的devtools::build_vignettes(vignettes = FALSE)
时,该过程顺利完成!
√ checking for file 'C:\Users\greg\Workspace\R\Packages\my_pkg/DESCRIPTION' ...
- preparing 'my_pkg': (640ms)
√ checking DESCRIPTION meta-information ...
- checking for LF line-endings in source and make files and shell scripts (384ms)
- checking for empty or unneeded directories
Removed empty directory 'my_pkg/inst/libs'
Omitted 'LazyData' from DESCRIPTION
- building 'my_pkg_0.0.0.9000.tar.gz'
Running "C:/Users/greg/R/bin/x64/Rcmd.exe" INSTALL \
"C:\Users\greg\AppData\Local\Temp\Rtmpozvh26/my_pkg_0.0.0.9000.tar.gz" --install-tests
* installing to library 'C:/Users/greg/R/library'
* installing *source* package 'my_pkg' ...
** using staged installation
** R
** inst
** tests
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
converting help for package 'my_pkg'
finding HTML links ... done
foo html
my_pkg-package html
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
*** arch - i386
*** arch - x64
** testing if installed package can be loaded from final location
*** arch - i386
*** arch - x64
** testing if installed package keeps a record of temporary installation path
* DONE (my_pkg)
Making 'packages.html' ... done
Now, the autocompletion works entirely as expected, and only the appropriate functions are exposed by my_pkg::
and my_pkg:::
respectively.现在,自动完成功能完全按预期工作,
my_pkg::
和my_pkg:::
分别只公开了适当的函数。
devtools::install(build_vignettes = TRUE)
or devtools::build()
devtools::install(build_vignettes = TRUE)
或devtools::build()
失败Yet there is one further plot twist.然而,还有一个进一步的情节转折。 When I use
devtools::install(
build_vignettes = TRUE
)
, or comparably devtools::build()
, I get a similar error to that with devtools::check()
:当我使用
devtools::install(
build_vignettes = TRUE
)
或类似的devtools::build()
时,我得到与devtools::check()
类似的错误:
√ checking for file 'C:\Users\greg\Workspace\R\Packages\my_pkg/DESCRIPTION' ...
- preparing 'my_pkg': (672ms)
√ checking DESCRIPTION meta-information ...
- installing the package to build vignettes
-----------------------------------
- installing *source* package 'my_pkg' ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
converting help for package 'my_pkg'
finding HTML links ... done
foo html
my_pkg-package html
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error : package 'my_pkg' is not installed for 'arch = x64'
Error: loading failed
Execution halted
ERROR: loading failed
- removing 'C:/Users/greg/AppData/Local/Temp/RtmpM7RbHr/Rinst504119422cd/my_pkg'
-----------------------------------
ERROR: package installation failed
Error in (function (command = NULL, args = character(), error_on_status = TRUE, :
System command 'Rcmd.exe' failed, exit status: 1, stdout + stderr (last 10 lines):
E> ** building package indices
E> ** installing vignettes
E> ** testing if installed package can be loaded from temporary location
E> Error : package 'my_pkg' is not installed for 'arch = x64'
E> Error: loading failed
E> Execution halted
E> ERROR: loading failed
E> * removing 'C:/Users/greg/AppData/Local/Temp/RtmpM7RbHr/Rinst504119422cd/my_pkg'
E> -----------------------------------
E> ERROR: package installation failed
Type .Last.error.trace to see where the error occurred
devtools::build_vignettes()
devtools::build_vignettes()
取得成功Bizarrely, despite the issues above with building vignettes, everything somehow runs smoothly when I call devtools::build_vignettes()
sans arguments or with dependencies = TRUE
:奇怪的是,尽管在构建小插图时存在上述问题,但当我调用
devtools::build_vignettes()
无参数或使用dependencies = TRUE
时,一切都以某种方式顺利运行:
i Building my_pkg vignettes
√ Creating 'doc/'
√ Adding '^doc$' to '.Rbuildignore'
√ Setting active project to '<no active project>'
√ Adding '/doc/' to '.gitignore'
√ Setting active project to '<no active project>'
i Moving backstory.html, intro.html, library.html, template.html, usage.html, backstory.R, intro.R, library.R, template.R, and usage.R to doc/
i Copying backstory.Rmd, intro.Rmd, library.Rmd, template.Rmd, and usage.Rmd to doc/
√ Creating 'Meta/'
√ Adding '^Meta$' to '.Rbuildignore'
√ Setting active project to '<no active project>'
√ Adding '/Meta/' to '.gitignore'
√ Setting active project to '<no active project>'
i Building vignette index
Assuming that the fault was mine, and that I had unwittingly introduced an issue somewhere within my R project, I switched to an entirely different Git branch.假设是我的错,并且我无意中在我的 R 项目中的某个地方引入了一个问题,我切换到了一个完全不同的 Git 分支。 The most recent commit to this branch had passed
devtools::check()
with flying colors.最近对该分支的提交通过了
devtools::check()
并取得了成功。 However, even after switching over to this "safe" branch, those same issues continued!然而,即使在切换到这个“安全”分支之后,同样的问题仍然存在!
Between that last successful check and when the issues began, I made no updates to:在最后一次成功检查和问题开始之间,我没有更新:
Likewise, the vignettes have been present since far earlier in the project.同样,这些小插曲在项目的早期就已经存在。
I'm hoping to roll out a proof of concept for my_pkg
in the rather near future, and the vignettes are quite essential to its usability.我希望在不久的将来
my_pkg
的概念验证,并且这些小插曲对其可用性非常重要。
Since " my_pkg
" is proprietary, I here anonymize my personal and organizational information (names, filepaths, etc.) as above.由于“
my_pkg
”是专有的,因此我在此匿名化我的个人和组织信息(名称、文件路径等),如上所述。
Would you mind sharing your DESCRIPTION file and the vignette header/meta information?
您介意分享您的说明文件和小插图标题/元信息吗?
The DESCRIPTION
file: DESCRIPTION
文件:
Package: my_pkg
Title: Proprietary Package for My Org
Version: 0.0.0.9000
Authors@R:
person(given = "Greg",
family = "Lastname",
role = c("aut", "cre"),
email = c("glastname@myorg.com"))
Description: The `my_pkg` package is a proprietary project for My Org,
and as such I have changed the names to project the innocent.
License: file LICENSE
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.2
URL: https://github.com/myorg/my_pkg
BugReports: https://github.com/my_org/my_pkg/issues
Suggests:
knitr,
rmarkdown,
testthat (>= 3.0.0)
Config/testthat/edition: 3
VignetteBuilder: knitr
Depends:
R (>= 2.10)
The vignette headers:小插图标题:
intro.Rmd
: intro.Rmd
:---
title: "A Catchphrase!"
author: "Gregory Lastname"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{A Catchphrase!}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
# Show no output.
eval = FALSE, results = "hide",
# Show no dialog.
message = FALSE, warning = FALSE,
# Show no errors.
error = TRUE, purl = FALSE,
# Default format.
collapse = TRUE, comment = "#>"
)
```
backstory.Rmd
: backstory.Rmd
:---
title: "A Reference, to Science Fiction"
author: "Gregory Lastname"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{A Reference, to Science Fiction}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
# Show no output.
eval = FALSE, results = "hide",
# Show no dialog.
message = FALSE, warning = FALSE,
# Show no errors.
error = TRUE, purl = FALSE,
# Default format.
collapse = TRUE, comment = "#>"
)
```
library.Rmd
---
title: "A Generic One-Liner"
author: "Gregory Lastname"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{A Generic One-Liner}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
# Show no output.
eval = FALSE, results = "hide",
# Show no dialog.
message = FALSE, warning = FALSE,
# Show no errors.
error = TRUE, purl = FALSE,
# Default format.
collapse = TRUE, comment = "#>"
)
```
template.Rmd
---
title: "A Well-Written Description"
author: "Gregory Lastname"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{A Well-Written Description}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
# Show no output.
eval = FALSE, results = "hide",
# Show no dialog.
message = FALSE, warning = FALSE,
# Show no errors.
error = TRUE, purl = FALSE,
# Default format.
collapse = TRUE, comment = "#>"
)
```
usage.Rmd
---
title: "An Exhortation!"
author: "Gregory Lastname"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{An Exhortation!}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
# Show no output.
eval = FALSE, results = "hide",
# Show no dialog.
message = FALSE, warning = FALSE,
# Show no errors.
error = TRUE, purl = FALSE,
# Default format.
collapse = TRUE, comment = "#>"
)
```
What do you see if you open the
.Rproj
file with a text editor?如果您使用文本编辑器打开
.Rproj
文件,您会看到什么?
The my_pkg.Rproj
file, as opened in MS Notepad.在 MS 记事本中打开的
my_pkg.Rproj
文件。 NOTE : This file has not been modified since the very initial commit.注意:自从最初的提交以来,该文件没有被修改过。
Version: 1.0
RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX
AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
LineEndingConversion: Posix
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
Does it work if you run
R CMD build/INSTALL ...
from the command line?如果您从命令行运行
R CMD build/INSTALL ...
是否有效?
I also built from the command line我也是从命令行构建的
greg@CO-GLASTNAME MINGW64 ~/Workspace/R
$ R CMD build C:/Users/greg/Workspace/R/Packages/my_pkg
but I got the same output echoed above:但我在上面得到了相同的输出:
* checking for file 'C:/Users/greg/Workspace/R/Packages/my_pkg/DESCRIPTION' ... OK
* preparing 'my_pkg':
* checking DESCRIPTION meta-information ... OK
* installing the package to build vignettes
-----------------------------------
* installing *source* package 'my_pkg' ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
converting help for package 'my_pkg'
finding HTML links ... done
foo html
my_pkg-package html
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error : package 'my_pkg' is not installed for 'arch = x64'
Error: loading failed
Execution halted
ERROR: loading failed
* removing 'C:/Users/greg/AppData/Local/Temp/RtmpgFIc2r/Rinst1cc0231a6b37/my_pkg'
-----------------------------------
ERROR: package installation failed
You are probably right and it is a problem with the vignette.你可能是对的,这是小插图的问题。 (but of course I can't be 100% sure, as I don't know your files)
(但当然我不能 100% 确定,因为我不知道你的文件)
About your confusion about the check()
and install()
runs:关于您对
check()
和install()
运行的困惑:
RStudio's “build and reload doesn't build vignettes
RStudio 的“构建和重新加载不会构建小插曲
That is why you probably have to run devtools::install() to get the error.这就是为什么您可能必须运行 devtools::install() 才能获得错误。
I'll post you some most likely issues with the vignette ( here is also a good longer tutorial ):我会向您发布一些最有可能与小插图有关的问题(这里也是一个很好的更长的教程):
First check the following things:首先检查以下几点:
The directory is called vignettes/ and not vignette/.该目录称为小插图/而不是小插图/。
Check that vignettes are not covered by .Rbuildignore检查 .Rbuildignore 未涵盖小插图
Ensure you have the necessary vignette metadata (your seemed good from the first look)确保你有必要的小插图元数据(你从第一眼看就很好)
Most likely these thing will be alright for you (but just to check).很可能这些东西对你来说没问题(但只是为了检查)。
In my opinion the most likely issue is, that your DESCRIPTION file does not contain all the necessary dependencies for your .Rmd vignettes在我看来,最可能的问题是,您的说明文件不包含 .Rmd 小插图的所有必要依赖项
Also better write:也最好写:
VignetteBuilder: knitr, rmarkdown
Still keep rmarkdown additionally in the Suggests.仍然在建议中另外保留 rmarkdown。 Also knitr to both, Suggests and VignetteBuilder.
也 knitr 到 Suggests 和 VignetteBuilder。
Even more important(!) you also need the packages, that are used in your .Rmd files in Suggests
.更重要的是(!)您还需要在
Suggests
的 .Rmd 文件中使用的包。 Since you are using RMarkdown I am assuming, there is some code in your vignettes.由于我假设您使用的是 RMarkdown,因此您的小插图中有一些代码。 Go through your code and look which packages you are using.
浏览您的代码并查看您正在使用哪些包。 Any packages used by the vignette should be declared in the
DESCRIPTION
.小插图使用的任何包都应在
DESCRIPTION
声明。
I could imagine this might also be the reason, why it seemingly worked once and then after changing nothing (in your opinion) it fails.我可以想象这也可能是原因,为什么它似乎工作一次,然后在没有改变任何东西(在你看来)之后它失败了。
Could be you still had all the required packages loaded in the background when it worked.当它工作时,您是否仍然在后台加载了所有必需的包。 So that it did not have an impact, that the packages were missing in
Suggests
.因此它不会产生影响,即
Suggests
中缺少软件包。
This would be my first guess, what the problem could be.这将是我的第一个猜测,可能是什么问题。 If this does not work, I would try removing vignettes, to see if it is a certain vignette that causes the problem.
如果这不起作用,我会尝试删除小插图,看看是否是某个小插图导致了问题。
As of now , no answer has been posted that solves the titular error.截至目前,尚未发布解决名义错误的答案。 I am posting this by way of clarification, to any users encountering the same error, that the error remains undiagnosed and unresolved.
我发布此消息是为了向遇到相同错误的任何用户澄清,该错误仍未得到诊断和解决。 Indeed, the error has persisted even after resetting my project via Git and reinstalling R (and Rtools and RStudio) from scratch.
事实上,即使在通过 Git 重置我的项目并从头开始重新安装 R(以及 Rtools 和 RStudio)后,该错误仍然存在。
My thanks to @SteffenMoritz and @Alexis for their tenacious debugging sessions.感谢@SteffenMoritz和@Alexis顽强的调试会话。 While our efforts were unsuccessful, I appreciate their time, effort, and friendliness.
虽然我们的努力没有成功,但我感谢他们的时间、努力和友好。 Anyone struggling with similar issues would do well to follow their advice, found in an answer and in the comments .
任何在类似问题上挣扎的人都会很好地遵循他们的建议,在答案和评论中找到。
I will update this post with any true solution I might encounter in the future.我会用我将来可能遇到的任何真正的解决方案来更新这篇文章。
What solved it in my case was switching from %\VignetteEngine{knitr::rmarkdown}
to %\VignetteEngine{knitr::knitr}
.在我的情况下解决它的方法是从
%\VignetteEngine{knitr::rmarkdown}
切换到%\VignetteEngine{knitr::knitr}
。 I have no idea why, but it stopped the error and putting back rmarkdown
instead of knitr
reproduced the error.我不知道为什么,但它停止了错误并放回
rmarkdown
而不是knitr
重现了错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.