I am having some trouble invoking devtools::test() via Ctrl+Shift+T. Seems like this might be an appropriate venue to ask this question.
==> devtools::test()
MY TESTS
Failed -------------------------------------------------------------------------
Error: RStudio not running
Execution halted
Exited with status 1.
I am able to run the tests manually by simply running the code in testthat and am also able to run the tests successfully using devtools::test(). Similarly devtools::check() works fine both from the console and in the build window. So that is, the tests pass, but the Ctrl+Shift+T option doesn't work. And this is a problem because it is such a useful feature. Any ideas?
I am using RStudio version: 1.1.350 and here is my session info:
> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 LC_MONETARY=English_Canada.1252 LC_NUMERIC=C
[5] LC_TIME=English_Canada.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] testthat_1.0.2 devtools_1.13.3
loaded via a namespace (and not attached):
[1] compiler_3.4.1 magrittr_1.5 R6_2.2.2 tools_3.4.1 withr_2.0.0 rstudioapi_0.7 yaml_2.1.14 crayon_1.3.3 memoise_1.1.0
[10] digest_0.6.12 fortunes_1.5-4
I suspect this error message is coming from the rstudioapi package. Are you trying to use that package within your tests? If so, how are you detecting whether RStudio is present as the front-end?
Tried on another machine and wasn't able to replicate the problem. Possibly due to rstudioapi though that isn't part of the tests nor the functions. I will have to work on a way to make this reproducible. Thanks for the response.
crayon is confused, because it uses env variables to detect the color support, and these are set in the build panel. But the build panel does not seem to support color. One workaround would be to unset RSTUDIO_CONSOLE_COLOR in the build pane. I don't think that I can fix this in crayon, because rstudioapi::isAvailable() is not a good test, it also returns FALSE until RStudio is initialized, so it is FALSE in .Rprofile.
The error message is a crayon bug, I assumed that if RSTUDIO is set to 1, then I can call rstudioapi::hasFun("getConsoleHasColor"), but this is not the case.