How to solve issue with package installation?

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:

  1. 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
  1. If I don't have renv active
  • Packages from CRAN will install fine, unless they need compilation. If they need compilation, they will fail.
  1. 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.

Hi,

Welcome to the RStudio community!

I feel your frustration as these type of issues can be so system dependent that it's sometimes nearly impossible to figure out what exactly is going on. I'm afraid I don't have a real answer to your question, but here are some things your might want to check or look into

  • I notice that all the error have the "The system cannot find the path specified" error in them. Path errors are often very vague and can be a nightmare to pinpoint, but maybe if you dig more you find a clue (I Googled a bit but not much luck)
  • Have you tried installing packaged from the base R terminal (so not RStudio). This is always a good way to see if RStudio is the cause or if it's your own system or R itself
  • Do you have any virus scanner / system restrictions that might interfere with install? If so, try and see if there might be a cause there
  • I don't know which operating system you have, but try and search for specific issues related to the system you use

Again, I'm sorry I don't have real solutions, but I just know how frustrating these things can be and maybe something I said might help in a small way

PJ

Hi Pieter, thanks for the help - as you say it is frustrating because it's such a vague error. After a lot of googling I found https://www.tenforums.com/general-support/122582-cmd-terminal-starts-system-cannot-find-path-specified.html which had the key for me. Looks like an old installation of Conda was being called for the AutoRun key in the registry, but I uninstalled it a month or two ago as I was no longer using it! Deleting the key has fixed the issues. So it wasn't really related to R at all, but OS config instead.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.