r-lib / remotes

Install R packages from GitHub, GitLab, Bitbucket, git, svn repositories, URLs
https://remotes.r-lib.org/
Other
336 stars 153 forks source link

`install_local()` fails due to "invalid 'type'" #645

Closed milanmlft closed 3 years ago

milanmlft commented 3 years ago

Running the example from remotes::install_local() I get:

dir <- tempfile()
dir.create(dir)
pkg <- download.packages("testthat", dir, type = "source")
remotes::install_local(pkg[, 2])
#> Error: Failed to install 'testthat' from local:
#>   invalid 'type'

Any idea what may be causing this?

The traceback shows:

traceback()
#> 7: stop(remote_install_error(remotes[[i]], e))
#> 6: value[[3L]](cond)
#> 5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 4: tryCatchList(expr, classes, parentenv, handlers)
#> 3: tryCatch(res[[i]] <- install_remote(remotes[[i]], ...), error = function(e) {
#>     stop(remote_install_error(remotes[[i]], e))
#> })
#> 2: install_remotes(remotes, dependencies = dependencies, upgrade = upgrade, 
#>                    force = force, quiet = quiet, build = build, build_opts = build_opts, 
#>                    build_manual = build_manual, build_vignettes = build_vignettes, 
#>                    repos = repos, type = type, ...)
#> 1: remotes::install_local(pkg[, 2])

Any help would be much appreciated!

PS: I get this same error on a few GHA runners so it does not seem to be related to my local setup.

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.1.1 (2021-08-10) #> os macOS Big Sur 10.16 #> system x86_64, darwin17.0 #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Brussels #> date 2021-09-02 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date lib source #> backports 1.2.1 2020-12-09 [1] CRAN (R 4.1.0) #> callr 3.7.0 2021-04-20 [1] standard (@3.7.0) #> cli 3.0.0 2021-06-30 [1] CRAN (R 4.1.0) #> crayon 1.4.1 2021-02-08 [1] CRAN (R 4.1.0) #> curl 4.3.2 2021-06-23 [1] CRAN (R 4.1.0) #> digest 0.6.27 2020-10-24 [1] CRAN (R 4.1.0) #> ellipsis 0.3.2 2021-04-29 [1] standard (@0.3.2) #> evaluate 0.14 2019-05-28 [1] CRAN (R 4.1.0) #> fansi 0.5.0 2021-05-25 [1] CRAN (R 4.1.0) #> fs 1.5.0 2020-07-31 [1] CRAN (R 4.1.0) #> glue 1.4.2 2020-08-27 [1] CRAN (R 4.1.0) #> highr 0.9 2021-04-16 [1] CRAN (R 4.1.0) #> htmltools 0.5.1.1 2021-01-22 [1] CRAN (R 4.1.0) #> knitr 1.33 2021-04-24 [1] CRAN (R 4.1.0) #> lifecycle 1.0.0 2021-02-15 [1] CRAN (R 4.1.0) #> magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.1.0) #> pillar 1.6.1 2021-05-16 [1] CRAN (R 4.1.0) #> pkgbuild 1.2.0 2020-12-15 [1] CRAN (R 4.1.0) #> pkgconfig 2.0.3 2021-06-17 [1] Github (r-lib/pkgconfig@b81ae03) #> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.1.0) #> processx 3.5.2 2021-04-30 [1] CRAN (R 4.1.0) #> ps 1.6.0 2021-02-28 [1] CRAN (R 4.1.0) #> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.1.0) #> R.cache 0.15.0 2021-04-30 [1] CRAN (R 4.1.0) #> R.methodsS3 1.8.1 2020-08-26 [1] CRAN (R 4.1.0) #> R.oo 1.24.0 2020-08-26 [1] CRAN (R 4.1.0) #> R.utils 2.10.1 2020-08-26 [1] CRAN (R 4.1.0) #> R6 2.5.0 2020-10-28 [1] CRAN (R 4.1.0) #> remotes 2.4.0 2021-06-02 [1] CRAN (R 4.1.0) #> reprex 2.0.0 2021-04-02 [1] CRAN (R 4.1.0) #> rlang 0.4.11 2021-04-30 [1] CRAN (R 4.1.0) #> rmarkdown 2.9 2021-06-15 [1] CRAN (R 4.1.0) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.1.0) #> stringi 1.6.2 2021-05-17 [1] CRAN (R 4.1.0) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.1.0) #> styler 1.4.1 2021-03-30 [1] CRAN (R 4.1.0) #> tibble 3.1.2 2021-05-16 [1] CRAN (R 4.1.0) #> utf8 1.2.1 2021-03-12 [1] CRAN (R 4.1.0) #> vctrs 0.3.8 2021-04-29 [1] standard (@0.3.8) #> withr 2.4.2 2021-04-18 [1] CRAN (R 4.1.0) #> xfun 0.24 2021-06-15 [1] CRAN (R 4.1.0) #> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.1.0) #> #> [1] /Users/milan/Library/R/x86_64/4.1/library #> [2] /Library/Frameworks/R.framework/Versions/4.1/Resources/library ```
milanmlft commented 3 years ago

After some more digging I found out that the problem is coming from remotes:::package_deps(). I re-ran the example after debug(remotes:::package_deps) and found that the likely culprit is a GitHub installation of pkgconfig, which for some reason has pkg_type == NULL:

Browse[2]> remote[vapply(remote, function(x) is.null(x$pkg_type), logical(1))]
#> [[1]]
#> $host
#> [1] "api.github.com"

#> $package
#> NULL

#> $repo
#> [1] "pkgconfig"

#> $subdir
#> NULL

#> $username
#> [1] "r-lib"

#> $ref
#> [1] "HEAD"

#> $sha
#> [1] "b81ae038aa5fe5d7c66c363d45a002cd8f0a4503"

#> attr(,"class")
#> [1] "github_remote" "remote"       

This seems similar to https://github.com/rstudio/renv/issues/221.

Removing and reinstalling pkgconfig did not resolve the problem however, now the invalid 'type' error comes from the packages diffobj and brio, which have pkg_type == "macos"... Is this normal?

Thanks in advance!

jimhester commented 3 years ago

pak set RemotePackageType to macos at one point, whech is likely where these entries come from. https://github.com/r-lib/remotes/issues/617

Unfortunately remotes passes the package type to available.packages(), which does not understand these types, I think the best thing to do would be to remove any package from your library which does not have a package type of source, binary or mac.binary.

jimhester commented 3 years ago

If you use the latest dev version of pak it should also avoid adding these entries when installing.

milanmlft commented 3 years ago

Thanks for the info!

So if I understand correctly, this problem is due to having previously installed those packages through pak, which adds the macos package type? Even though I'm not using pak right now to locally install the test package.

In any case, removing those packages and reinstalling them with install.packages() does indeed solve the problem, so I guess I will stick with that for now.

jimhester commented 3 years ago

yes, that is correct.