devtool::test() gives warning, R CMD check ok - r

devtools::test() gives me a warning each time one of my internal function is ran. But when I run the incriminated codes in the console there is no warning. In addition R CMD check or devtools::check() don't complain about these lines of code (no error, no warning, no note).
So it means that devtools::test() run the tests using different settings compared to the regular R environment and compared to R CMD check.
I investigated and I didn't find any hint even if I found several topics with more a less comparable questions. This is not really a problem because the outputs are good and the problem does not occur on CRAN or when running the code. But I would like to remove these warning from devtools::test().
Please note that my question does not concern how to fix the warnings but how to get a chance to reproduce the problem in attempt to solve it.

Related

devtools::check generates an error (install options '--no-html --no-multiarch) at seemingly randomly times

I am creating my own package and use devtools to document and check the package. About 50% of the time that I run devtools::check() it ends with this error:
❯ checking whether package 'snafun' can be installed ... ERROR See below...
── Install failure ─────────────────────────────────────────────────────────────────────────────────────────────────
install options '--no-html --no-multiarch
However, this only happens about half the time. Sometimes it doesn't and sometimes it does. I can run devtools::check several times in a row (without making any change to the code or the session in between) and get this error on half of the runs, and on the other half not. And sometimes it seems to help if I restart the session in between an other times it makes no difference.
I have tried playing with the arguments of devtools::check, but that doesn;t seem to affect the error (which could be related to this being an "Install failure" and devtools::check doesn't have install arguments).
I am puzzled. I have the following questions:
what does this error even mean? Is it problematic?
what can make it occur and disappear seemingly randomly?
what might be a direction to solve this?
ps the package is quite large, so I can't really turn this into a reprex
I got exactly the same problem and I solved it installing the rcmdcheck package.
install.packages("rcmdcheck")
library(rcmdcheck)
rcmdcheck('MyPath/MyPackage')

Why does R source() sometimes work and sometimes gives an error

I have the API credentials in one separate R script to keep it out of Git. I want to run this script in the beginning of the scripts that actually interact with the different servers. I have successfully used the same strategy for all my global functions.
setwd("G:/script")
source("API_credentials.R") # gives always an error
# > source("API_credentials.R")
# Error: '\s' is an unrecognized escape in character string starting ""g:\s"
source("ProVeg_functions.R") # runs fine
Problem:
Why does the first source() not work, while the second one does? The error message does not make any sense to me.
Solutions tried:
I have tried different escape chars \.
I have tried writing full path & file names.
I have tried putting the file name in as a variable, which gets its
content from a dir() search, to make sure that the file exists and
the name is correctly written.
Order of source() does not change situation.
Isolating the piece of code with error, and restarting R.
upgraded all my packages and R to version 4.0.2.
The API_credentials.r script works fine when run on its own. the Sys.setenv() works fine and I can read the API keys with Sys.getenv().
I am not sure if it is related to my problem, but if I do usethis::edit_r_environ() I can not see my API keys.
Setup
Windows 10, R-Studio 1.3.1093, R version 4.0.2 (2020-06-22)
I mistakenly assumed that the error message was related to the script calling the API_credentials.R, but it actually was an error message indicating an error in the API_credentials.R script. Fixed a typo and all is good.

Why am I getting a KeyError message?

Every time I call Pkg.Update() I get the following message:
KeyError: key "RDataSets" not found
I am aware that the correct name of the package is RDatasets and not RDataSets. When I first tried to install this package I must have made a mistake and entered a capital "S." Actually the package initially did not install and I had to painfully call Pkg.clone() for several packages it depended on.
Is this an indication of a serious problem? Everything seems to be working fine, but I am just starting (again) with Julia, so I am not sure. Also, can this problem be fixed?

R CMD check stops at "checking Rd cross-references"

I am using devtools::check(document=FALSE,args=c('--no-multiarch')) to perform the checks for my package.
When the above command performs R --vanilla CMD check "C:\sometmpfolder/mypackage.tar.gz" --timings --no-multiarch,
it stops at
* checking Rd cross-references ...
i.e., this is the last line in mypackage.Rcheck/00check.log. There is no error message - the check seems to freeze.
I use roxygen2 to create my documentation. The cross references that I use are of the form \link{somefunction} and \link[somepkg]{somefunction}.
I am running R 3.1.2 on a Win 7 machine.
But I think that I have seen a similar behaviour with earlier versions of R and without roxygen2 as well.
Do you guys know why the check stops at the cross-references?
It turned out that an incorrect statement of the form
\link[somepkg]{somefunction}
was the problem. In my case I used the incorrect command \link[reshape]{melt} although it should be \link[reshape2]{melt}.
This caused the Rd cross-reference check to take forever (actually, it finished after nearly one hour). After correcting to \link[reshape2]{melt} the Rd cross-reference check only took a minute or so.

Running command had status 1

I've tried to run command in R 2.15.2
rsaga.geoprocessor(lib="ta_channels", module=0, param=list(ELEVATION="DEMflt.sgrd", CHNLNTWRK=paste("channels", i, ".sgrd", sep=""), CHNLROUTE="channel_route.sgrd", SHAPES="channels.shp", INIT_GRID="DEMflt.sgrd", DIV_CELLS=3, MINLEN=40), show.output.on.console=FALSE)
and I'm constantly getting this warning:
Warning message:
running command '"C:/Users/Nenad/Documents/R/win-library/2.15/RSAGA/SAGA-GIS/saga_cmd.exe" ta_preprocessor 2 -DEM "DEM1.sgrd" -RESULT "DEMflt.sgrd" -MINSLOPE "0.05"' had status 1
I use windows 8 and also tried to ran R as admin.
Any idea what is the problem? Thanks!
Idk how actual it is, but I've been struggling with "had status 1" warning a lot. Especially it got really annoying when I tried to use seasonal package to conduct the X13-ARIMA-SEATS seasonal decomposition of time series. The seasonal::seas command just didn't work, because in the code of this command there is a stop condition when running a certain stuff with cmd.exe returns non-zero status. While, as it was mentioned before, 'status 1' doesn't prevent command execution, in case of seasonal package it does.
The problem in my case was caused by some mistake in Windows Registry (Win 10), that in turn caused warning System cannot find the path specified when launching CMD.exe or PowerShell, which caused warning inside R as well. So to fix it:
Press Win+R -> regedit
In HKEY_CURRENT_USER\SOFTWARE\Microsoft\Command Processor folder clean the value of Autorun record (it should be empty)
Do the same for Autorun in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor
After these actions annoying warning with "has status 1" has gone and seasonal::seas started to work perfectly.
Hope it will be usefull for somebody.
Running system commands from R can be really tricky. In my experience, as long as the exit code is not 127 then the command did run, and you could use the intern=TRUE switch in the system command for a more verbose output. If you run the command again, the warning message could contain a errmsg attribute as well for some more info. hth

Resources