I'm having an issue when installing packages which is causing major headaches for me. I feel like I've tried everything, and am nowhere close to solving the issue!
I am working on a local R package which uses renv
for package management. The issue surrounds installing packages, both from CRAN and when trying to build/check/install my own local package. It seems to be related to the system path somehow, though I'm pretty sure I've got things set up correctly.
I am using R 4.1.2 and the latest version of RStudio. I have RTools 4 installed as well.
The different scenarios are:
- When I have
renv
active and try installing packages from CRAN
Using jose
as an example...
- Any package that I install will fail if I simply use
install.packages("pkg")
> install.packages("jose")
Retrieving 'https://cran.rstudio.com/src/contrib/jose_1.2.0.tar.gz' ...
OK [file is up to date]
Installing jose [1.2.0] ...
FAILED
Error installing package 'jose':
================================
The system cannot find the path specified.
* installing to library 'C:/Users/BEVJ/r-sdk/renv/library/R-4.1/x86_64-w64-mingw32'
* installing *source* package 'jose' ...
** package 'jose' successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
converting help for package 'jose'
finding HTML links ... done
base64url_encode html
jwk html
jwt_claim html
jwt_encode html
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (jose)
Error: install of package 'jose' failed [error code 1]
- If I use
source = TRUE
(or, for some reason,verbose = TRUE
..) the package will install successfully sometimes, though it fails when the package or one of its dependencies needs compilation.
> install.packages("jose", source = TRUE)
Installing package into ‘C:/Users/BEVJ/r-sdk/renv/library/R-4.1/x86_64-w64-mingw32’
(as ‘lib’ is unspecified)
There is a binary version available but the source version is later:
binary source needs_compilation
jose 1.1.0 1.2.0 FALSE
installing the source package ‘jose’
trying URL 'https://cran.rstudio.com/src/contrib/jose_1.2.0.tar.gz'
Content type 'application/x-gzip' length 505085 bytes (493 KB)
downloaded 493 KB
The system cannot find the path specified.
* installing *source* package 'jose' ...
** package 'jose' successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
converting help for package 'jose'
finding HTML links ... done
base64url_encode html
jwk html
jwt_claim html
jwt_encode html
** 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 (jose)
The downloaded source packages are in
‘C:\Users\BEVJ\AppData\Local\Temp\2\RtmpQ5lf3Q\downloaded_packages’
Warning message:
In utils::install.packages(pkgs, ...) :
installation of package ‘jose’ had non-zero exit status
- If I don't have
renv
active
- Packages from CRAN will install fine, unless they need compilation. If they need compilation, they will fail.
- Regardless of whether or not I have
renv
active and I try and install, build or check my own package
- Installation fails:
> devtools::check()
### Some other unrelated stuff...
...
...
The system cannot find the path specified.
√ checking for file 'C:\Users\BEVJ\r-sdk/DESCRIPTION'
- preparing 'datalabSDK': (8.4s)
√ checking DESCRIPTION meta-information ...
- installing the package to build vignettes
-----------------------------------
The system cannot find the path specified.
- installing *source* package 'datalabSDK' ...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
### I've omitted the help indices as they take up so many lines
...
...
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
- DONE (datalabSDK)
-----------------------------------
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> get_scopes html
E> get_token_url html
E> ** building package indices
E> ** installing vignettes
E> ** testing if installed package can be loaded from temporary location
E> ** testing if installed package can be loaded from final location
E> ** testing if installed package keeps a record of temporary installation path
E> * DONE (datalabSDK)
E> -----------------------------------
E> ERROR: package installation failed
Type .Last.error.trace to see where the error occurred
Fixes I've Tried
Various combinations of the following:
- Restarting PC
- Completely uninstalling and reinstalling R, RStudio and RTools
- Removing R and RTools related paths from the system path and re-adding
I've tried this with a different project as well, and that has the same issue, so I'm led to believe it's a problem with my PC config or with R / RTools rather than the project itself. The last person that ran the project on their PC didn't have any issues but that was a few weeks ago.
I think this topic is a related issue, and I note that the author of that post didn't manage to find a solution. Does anyone have any ideas of how I can proceed? I have spent quite a while trying to get this to work.