Can't install package 'remotes' when trying to install 'devtools'

I'm trying to install devtools on a new installation of R 3.6 on a Windows 10 machine inside of RStudio 1.2.1335, but I keep getting the follow error:

> install.packages('remotes')
Installing package into ‘\\pna401f7070/<user>/R/win-library/3.6’
(as ‘lib’ is unspecified)

  There is a binary version available but the source version is later:
        binary source needs_compilation
remotes  2.0.4  2.1.0             FALSE

installing the source package ‘remotes’

trying URL 'https://cran.rstudio.com/src/contrib/remotes_2.1.0.tar.gz'
Content type 'application/x-gzip' length 131622 bytes (128 KB)
downloaded 128 KB

* installing *source* package 'remotes' ...
** package 'remotes' successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in findpack(package, lib.loc) : 
  there is no package called 'remotes'
Calls: <Anonymous> -> findpack
Execution halted
ERROR: lazy loading failed for package 'remotes'
* removing '\\pna401f7070/<user>/R/win-library/3.6/remotes'
Warning in install.packages :
  installation of package ‘remotes’ had non-zero exit status

The downloaded source packages are in
	‘C:\Users\<user>\AppData\Local\Temp\RtmpAN2mrL\downloaded_packages’

I have RTools3.5 installed, and have confirmed that it's accessible by installing other packages from source. What are some things I can do to try to debug this issue?

1 Like

Setting options(pkgType="binary") seems to have solved the issue, but I'd like to better understand what's going on that prevented it from installing from source.

1 Like

This appears to have just been a permission issue. Changing the directory to a non-mapped drive (mapped drives are the preferred location in my org for users to save data so that they're not interacting with C:/ directly) removes all errors.

1 Like

@Bryan I'm glad you were able to figure out the issue!

Could you explain your solution more? Which directory did you change? Did you have to manually set lib when you called install.packages()?

So I ended up creating a .Rprofile script by first creating an environment variable called R_PROFILE_USER which held the file path to where I'd be saving the .Rprofile file ("C:/users//Documents/.Rprofile"). I then made that file, which was comprised solely of the following:

.First <- function() {
    .libPaths(c("c:/users/<user>/R/library/3.6", .libPaths()[2]))
}

R now knew to not look in the default location, which could be found with path.expand("~"), for packages, and instead look on my C:/ drive. As a result, I did not need to specify lib when calling install.packages().

It's worth pointing out that this is typically considered bad practice. See this thread for some insight from Henrik Bengtsson on why specifying your own library for R packages to be saved can be problematic. The only reason I'm doing it in this situation is because the location R wanted to use by default was causing issues.

Hope that helps.

1 Like

@Bryan Thanks for sharing your solution!

Did you try directly setting the environment variable R_LIBS_USER="c:/users/<user>/R/library/3.6"?

@jdblischak - No, I didn't know that was a thing. But I'm going to now! Thanks!

1 Like

You can read a concise introduction of the R startup configuration options in the chapter R Startup in What They Forgot to Teach You About R. For all the gory details, you can also read the man page ?Startup.

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