remotes
remotes copied to clipboard
Feature Request: Add support to install packages from r-universe
Integration with https://r-universe.dev/ would be excellent. I'd love to be able to do something like:
remotes::install_runiverse("maelle/goodpress")
# equivalent(-ish) to
remotes::install_cran("goodpress", repos = "https://maelle.r-universe.dev")
A similar syntax for Remotes would also be helpful:
Remotes:
runiverse::maelle/goodpress
Can I also suggest:
remotes::install_universe("maelle")
To install all packages in a universe.
Are there any developments on this feature?
I think I'd like if we could run remotes::install_deps() without having to specifically set the options(repos = "r-universe").
I tried with a URL like Remotes: url::https://thinkr-open.r-universe.dev/src/contrib/fusen_0.4.0.9000.tar.gz.
This works, but this requires to set the version of the package. And once a new version arise, the installation does not work anymore.
install_deps() is particularly useful in Docker environments reading from DESCRIPTION file to install the package.
Or maybe {pak} is better suited for this now?
Thank you.
It is unlikely that this would be implemented, because it is not very hard to set the repos, and setting it is a better solution, anyway.
it is not very hard to set the
repos, and setting it is a better solution, anyway.
One reason setting repos isn't always a better solution is that a package may be included in multiple universes and this would require users to appropriately order repos or manually modify repos around the call to the package installation function to ensure the correct version is installed.
And even though it's "not very hard to set repos", it's still annoying, adds a decent bit of friction to the process, and is also easy to do incorrectly — my example above probably fails
remotes::install_cran("goodpress", repos = "https://maelle.r-universe.dev/")
because the maelle universe needs to be added to repos in addition to a CRAN repo, whereas the repos argument replaces the current repos option.
This should work well usually:
remotes::install_cran(
"goodpress",
repos = c("https://maelle.r-universe.dev/", getOption("repos"))
)
Maybe in pak we could have a way to specify that a package is in a specific repository, but AFAICT that is often not enough for R-universe repos, because dependencies would need to be installed from R-universe as well. This is why it is better to set the repo.
It is unlikely that this would be implemented, because it is not very hard to set the
repos, and setting it is a better solution, anyway.
Sorry if this is a stupid question, but how would I go about doing this for a transitive r-universe dependency in a DESCRIPTION file?
Suppose I want to write a package A hosted in X.r-universe.dev that depends on a package B in Y.r-universe.dev. Do I need to let the users installing A know about the dependency on B in repo Y at installation time and get them to do a:
options(repo=c(
X = 'https://X.r-universe.dev',
Y = 'https://Y.r-universe.dev',
CRAN = 'https://cloud.r-project.org'))
))
before they install.packages("A")? If so I can see that getting messy.
I'd like to make the additional repository explicit in package A's DESCRIPTION (maybe using Remotes: or equivalent), so B can be automatically installed, but I can't figure out if that is possible.
I am not sure, but I think you are supposed to add a Remotes entry to the dependency's GH repo, and then R-universe will add that package as well to your R-universe. So no need to set multiple repos.
IDK what is a good solution to namespacing and scattered R-universe repos in general, though.
Maybe this can/should be done with Additional_repositories: in the DESCRIPTION, but I'm struggling to find a good example.
If you add a GitHub entry in the "Remotes" field, you lose the benefit of r-universe.
Some IT services block whatever comes from GitHub, but they let pass installations from r-universe. ¯\_(ツ)_/¯
That is why I find r-universe interesting. Also r-universe tries to build the package before putting it in prod, which is a guarantee that, at least, you can install it. If the last version on "main" fails, you'll get the previous working one on r-universe
The r-universe/help discussions here suggest @gaborcsardi's answer is the current approach, you either include the package you depend on into your own r-universe, or that will happen automatically if one of your r-universe packages references any github url as a remote.
I can still see it getting messy though if there is a large r-universe transitive dependency network, all of which would have to be imported into your own repository, and for a frequently depended on r-universe package, multiple universes will have to rebuild the package each and every time it is updated.
I am really just starting package development in R, so forgive me if the question does not fit here, but this seems to be the most related resource I found.
My problem is that the package I am developing depends on another package hosted on r-universe.dev and I am unsure how to add this in the DESCRIPTION file?
I tried with usethis::use_dev_package("remotepackage", type = "Imports", remote = "r-universe::user/remotepackage") which adds the package to the DESCRIPTION like this:
Imports:
remotepackage,
Remotes:
r-universe::user/remotepackage
But this does not seem to work.
When trying to install my package from local source with the dependent remote r-universe package not yet installed
install.packages("path/mypackage.tar.gz", repos = NULL, type="source")
I get
ERROR: dependency 'remotepackage' is not available for package 'mypackage'
* removing 'C:/Program Files/R/R-4.4.0patched/library/mypackage'
Warning in install.packages :
installation of package ‘path/mypackage.tar.gz’ had non-zero exit status
it works without error if the remote package is already installed.
When I trying to install it from GitHub with devtools::install_github("user/mypackage")
I get the following error no matter if the dependent remote r-universe package is already installed or not
Using GitHub PAT from the git credential store.
Downloading GitHub repo user/mypackage@HEAD
Error: Failed to install 'mypackage' from GitHub:
Unknown remote type: r-universe
object 'r-universe_remote' of mode 'function' was not found
Any thoughts?
I am unsure how to add this in the DESCRIPTION file?
You cannot. You'll have to ask your users to configure their repositories to include the R-universe repos that you need.
I am unsure how to add this in the DESCRIPTION file?
You cannot. You'll have to ask your users to configure their repositories to include the R-universe repos that you need.
thanks for the super quick response. Just for my understanding, is there any resource about why this is not possible?
Not really. It is usually hard to prove that something does not exist.
Basically it comes down to this:
- R packages can officially only depend on packages in CRAN-like repositories.
- Configuring CRAN-like repositories is up to the user, not the package.
- There are some unofficial extensions (i.e. they are not used or even allowed on CRAN) to specify packages from other sources, e.g. https://pak.r-lib.org/reference/pak_package_sources.html#the-remotes-field and similarly in the remotes package, but these do not currently let you specify a package in a CRAN-like repository.
(For completeness, there is a DESCRIPTION field to specify additional repositories: Additional_repositores, but that is not used when installing packages. Or for anything, really. See "Writing R Extensions".)