@rii@mstei@ m@iii@g oii gm@ii@com
2025-Feb-06 17:36 UTC
[R] install.packages and package dependencies
It appears that install.packages does not automatically install package dependencies when the package is installed via a URL. As an example, here is what I get when I attempt to install the latest ggplot2 tarball via its URL on CRAN:> install.packages("https://cran.r-project.org/src/contrib/ggplot2_3.5.1.tar.gz") inferring 'repos = NULL' from 'pkgs' trying URL 'https://cran.r-project.org/src/contrib/ggplot2_3.5.1.tar.gz' Content type 'application/x-gzip' length 3604371 bytes (3.4 MB) =================================================downloaded 3.4 MB ERROR: dependencies ?cli?, ?glue?, ?gtable?, ?isoband?, ?lifecycle?, ?rlang?, ?scales?, ?tibble?, ?vctrs?, ?withr? are not available for package ?ggplot2? * removing ?/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/ggplot2? Warning in install.packages : installation of package ?/var/folders/m7/ztk511fj6vl4m6bw7vh47nk40000gn/T//RtmpmmFBOH/downloaded_packages/ggplot2_3.5.1.tar.gz? had non-zero exit status>Is there a parameter I can give to install.packages so that it will automatically install all the packages the package (in this example ggplot2) needs? I've read the documentation of install.packages several times, and am confused by the interplay of the various parameters. When I type getOption('repos') I get: CRAN "https://cran.rstudio.com/" attr(,"RStudio") [1] TRUE Without this it looks like installing from a URL is a 2-step process: install.packages(c(<packages the package needs>)) install.packages("<url of package tarball>") I am aware that there are some contributed packages (such as devtools and remotes) that do this for you in a single line. But I am curious whether this is possible via install.packages alone. [[alternative HTML version deleted]]
I don't think install.packages() can do what you want. If you are specifying a URL, then install.packages() assumes it has no way to know where the other dependencies are supposed to come from. The typical way I install an unusual version of a package is to install the CRAN version first (install.packages("ggplot2") will do that, and will get all the deps), then reinstall the special version, and hope I've got all the right dependencies. Duncan Murdoch On 2025-02-06 12:36 p.m., arilamstein at gmail.com wrote:> It appears that install.packages does not automatically install package > dependencies when the package is installed via a URL. As an example, here > is what I get when I attempt to install the latest ggplot2 tarball via its > URL on CRAN: > >> install.packages(" > https://cran.r-project.org/src/contrib/ggplot2_3.5.1.tar.gz") > inferring 'repos = NULL' from 'pkgs' > trying URL 'https://cran.r-project.org/src/contrib/ggplot2_3.5.1.tar.gz' > Content type 'application/x-gzip' length 3604371 bytes (3.4 MB) > =================================================> downloaded 3.4 MB > > ERROR: dependencies ?cli?, ?glue?, ?gtable?, ?isoband?, ?lifecycle?, > ?rlang?, ?scales?, ?tibble?, ?vctrs?, ?withr? are not available for package > ?ggplot2? > * removing > ?/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/ggplot2? > Warning in install.packages : > installation of package > ?/var/folders/m7/ztk511fj6vl4m6bw7vh47nk40000gn/T//RtmpmmFBOH/downloaded_packages/ggplot2_3.5.1.tar.gz? > had non-zero exit status >> > > Is there a parameter I can give to install.packages so that it will > automatically install all the packages the package (in this example > ggplot2) needs? I've read the documentation of install.packages several > times, and am confused by the interplay of the various parameters. When I > type getOption('repos') I get: > > CRAN > "https://cran.rstudio.com/" > attr(,"RStudio") > [1] TRUE > > Without this it looks like installing from a URL is a 2-step process: > > install.packages(c(<packages the package needs>)) > install.packages("<url of package tarball>") > > I am aware that there are some contributed packages (such as devtools and > remotes) that do this for you in a single line. But I am curious whether > this is possible via install.packages alone. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide https://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
On Thu, 6 Feb 2025 09:36:23 -0800 arilamstein at gmail.com wrote:> It appears that install.packages does not automatically install > package dependencies when the package is installed via a URL. [...] > When I type getOption('repos') I get: > > CRAN > "https://cran.rstudio.com/" > attr(,"RStudio") > [1] TRUEDo you set this value somewhere (via an environment variable or start up file)? Or is it this value because you use RStudio as IDE? If you use RStudio, please be aware that RStudio has its own version of install.packages(): RStudio> install.packages function (...) .rs.callAs(name, hook, original, ...) <environment: 0x12a530f00> So if you are using RStudio, you will have to talk with Posit about changing the behaviour of install.packages(). If you want the behaviour of utils::install.packages() to change, I am sure that R-Core will consider any diff that implements the new/improved behaviour. :-) Cheers, Berwin
Apparently Analagous Threads
- Best way to handle dependency on non-CRAN package / large data package?
- Best way to handle dependency on non-CRAN package / large data package?
- R Package: 'ggbreak' in Dockerfile
- Best way to handle dependency on non-CRAN package / large data package?
- R Package: 'ggbreak' in Dockerfile