crancache icon indicating copy to clipboard operation
crancache copied to clipboard

Mac OS not caching

Open kenahoo opened this issue 5 years ago • 1 comments

I tracked a problem down to this bit of code in get_cache_dir_for_file(file):

  which <- if (grepl("\\.zip$", file)) {
    if (.Platform$pkgType == "win.binary") {
      "platform"
    }

  } else if (grepl("\\.tgz$", file)) {
    if (grepl("^mac.binary", .Platform$pkgType)) {
      "platform"
    }

  } else if (grepl("\\.tar\\.gz$", file)) {
    ## This also includes non-standard (Linux, Solaris, etc.) binaries
    "source"
  }

  get_cache_package_dirs()[[paste0(prefix, which)]]

If the argument file is a string like ".../reshape2_1.4.3.tgz" and .Platform$pkgType is "source", then I'm ending up with which equal to NULL. So at the end of the function, it's trying to do get_cache_package_dirs()[["cran/"]], but that's not a valid key, so I get this error:

Error in get_cache_package_dirs()[[paste0(prefix, which)]] : 
  subscript out of bounds

The names of get_cache_package_dirs() are:

Browse[8]> names(get_cache_package_dirs())
[1] "cran-bin/source"  "cran/platform"    "cran/source"      "bioc-bin/source" 
[5] "bioc/platform"    "bioc/source"      "other-bin/source" "other/platform"  
[9] "other/source"    

It looks like there are several paths through the which assignment code that result in NULL.

The consequence of this is that the requested package does get installed, but if I run the same install_packages('pkgname') command again, neither the binary nor the source are found in the cache.

kenahoo avatar Apr 30 '19 22:04 kenahoo

Wondering if you have thoughts on this.

Here's the practical effect - the binary package doesn't get cached and used for the next installation:

> library(crancache)
> install_packages('reshape')
Installing package into ‘/Users/kwilliams/R/library/3.5’
(as ‘lib’ is unspecified)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 42558  100 42558    0     0  65218      0 --:--:-- --:--:-- --:--:-- 65273
* installing *source* package ‘reshape’ ...
** package ‘reshape’ successfully unpacked and MD5 sums checked
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (reshape)

The downloaded source packages are in
	‘/private/var/folders/zp/hj5hqfw970z0_78mrb_802lm0001z9/T/RtmpuPaQ8H/downloaded_packages’
Adding ‘reshape_0.8.8.tar.gz’ to the cache
> install_packages('reshape')
Installing package into ‘/Users/kwilliams/R/library/3.5’
(as ‘lib’ is unspecified)
* installing *source* package ‘reshape’ ...
** package ‘reshape’ successfully unpacked and MD5 sums checked
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (reshape)

The downloaded source packages are in
	‘/private/var/folders/zp/hj5hqfw970z0_78mrb_802lm0001z9/T/RtmpuPaQ8H/downloaded_packages’

kenahoo avatar May 15 '19 21:05 kenahoo