Skip to content

Specify extra repos in pkg_install() #306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bwiernik opened this issue Jun 25, 2021 · 3 comments
Closed

Specify extra repos in pkg_install() #306

bwiernik opened this issue Jun 25, 2021 · 3 comments

Comments

@bwiernik
Copy link

With base install.packages(), it's possible to specify additional repos to search in addition to the ones listed in options("repos") with the repos argument:

install.packages('correlation', repos = 'https://easystats.r-universe.dev')

This is convenient, and I've found also easier to explain to my students and users of my packages. It would be nice to be able to do similarly with pkg_install() to add an extra repo to the list at function runtime:

pak::pkg_install('correlation', repos = 'https://easystats.r-universe.dev')
@gaborcsardi
Copy link
Member

You can add extra repos with repo_add():

pak::repo_add(easy = "https://easystats.r-universe.dev")
❯ pak::repo_get()
# A tibble: 6 x 5
  name        url                                  type   r_version bioc_version
  <chr>       <chr>                                <chr>  <chr>     <chr>
1 CRAN        https://cloud.r-project.org          cran   *         NA
2 easy        https://easystats.r-universe.dev     cranl*         NA
3 BioCsoft    https://bioconductor.org/packages/3bioc   4.1.0     3.13
4 BioCann     https://bioconductor.org/packages/3bioc   4.1.0     3.13
5 BioCexp     https://bioconductor.org/packages/3bioc   4.1.0     3.13
6 BioCworkflhttps://bioconductor.org/packages/3bioc   4.1.0     3.13
pak::meta_list("correlation")
# A tibble: 4 x 32
  package  version depends suggests   license imports   linkingto archs enhances
  <chr>    <chr>   <chr>   <chr>      <chr>   <chr>     <chr>     <chr> <chr>
1 correla0.6.1   R (>="BayesFac… GPL-3   "bayesteNA        NA    NA
2 correla0.6.1   R (>="BayesFac… GPL-3   "bayesteNA        NA    NA
3 correla0.6.2   R (>="BayesFac… GPL-3   "bayesteNA        NA    NA
4 correla0.6.2   R (>="BayesFac… GPL-3   "bayesteNA        NA    NA
# … with 23 more variables: os_type <chr>, priority <chr>,
#   license_restricts_use <chr>, license_is_foss <chr>, repodir <chr>,
#   platform <chr>, rversion <chr>, needscompilation <chr>, ref <chr>,
#   type <chr>, direct <lgl>, status <chr>, target <chr>, mirror <chr>,
#   sources <list>, filesize <int>, sha256 <chr>, sysreqs <chr>, built <chr>,
#   published <dttm>, deps <list>, md5sum <chr>, path <chr>
pak::pkg_install('correlation')
✔ Updated metadata database: 1.11 MB in 3 files.Updating metadata databaseWill install 5 packages.Will download 3 CRAN packages (5.14 MB), cached: 2 (0 B).
+ bayestestR    0.10.0  ⬇ (3.29 MB)
+ correlation   0.6.2
+ datawizard    0.1.0   ⬇ (269.33 kB)
+ insight       0.14.2
+ parameters    0.14.0  ⬇ (1.57 MB)
ℹ Getting 3 pkgs (5.14 MB), 2 cachedGot datawizard 0.1.0 (macos) (269.33 kB)
✔ Got parameters 0.14.0 (macos) (1.57 MB)
✔ Got insight 0.14.2 (macos) (1.74 MB)
✔ Got bayestestR 0.10.0 (macos) (3.29 MB)
✔ Got correlation 0.6.2 (macos) (3.69 MB)
✔ Downloaded 5 packages (10.57 MB)in 2.5sInstalled datawizard 0.1.0  (115ms)
✔ Installed bayestestR 0.10.0  (234ms)
✔ Installed insight 0.14.2  (289ms)
✔ Installed parameters 0.14.0  (325ms)
✔ Installed correlation 0.6.2  (268ms)
✔ 1 + 4 pkgs | kept 0, updated 0, new 5 | downloaded 5 (10.57 MB) 14.1s

@bwiernik
Copy link
Author

bwiernik commented Jun 25, 2021

I'm aware of that. My point is that this is a more confusing operation for a one-off package installation:

pak::repo_add(easy = "https://easystats.r-universe.dev")
pak::pkg_install("correlation")

than:

pak::pkg_install("correlation", repos = "https://easystats.r-universe.dev")

Given the increasing prevalence of instructions like this (including in the pak readme):

install.packages("correlation", repos = "https://easystats.r-universe.dev")

it would help to eliminate friction if pak::pkg_install could be dropped in there without needing additional modifications:

pak::pkg_install("correlation", repos = "https://easystats.r-universe.dev")

A big part of my thinking there is that pak is becoming a much smoother approach to installation, and I am considering incorporating it into teaching to new R users as a unified way to install packages. Being able to say "if you're following instructions somewhere, you can replace either install.packages() or remotes::install_github() with pak::pkg_install() to take advantage of pak's headache-removing features" would be really useful.

@gaborcsardi
Copy link
Member

I do not want to add many parameters to pkg_install(), because it clutters the UI. I would also need to add them to the 10-20 other pak functions that deal with repos, which seems like a lot of extra code and code paths, with only a small benefit. I think it is not too hard to set up the repo separately.

Also, I expect that people copy-paste installation instructions from the README, so I don't think it matters if it is one line or two.

Being able to say "if you're following instructions somewhere, you can replace either install.packages() or remotes::install_github() with pak::pkg_install() to take advantage of pak's headache-removing features" would be really useful.

That will only work in the simplest cases, because pkg_install() is not a drop-in replacements for these.

Btw.

install.packages(..., repos = "https://....r-universe.dev")

only works if the r-universe repo is self-contained, because it omits CRAN from your repos. So in reality you would need something like

install.packages(
  ..., 
  repos = c(
    runiverse = "https://....r-universe.dev", 
    CRAN = "https://cloud.r-project.org"
  )
)

This also gets more complicated if you have configured Bioconductor or other repos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants