[R] install.packages and package dependencies

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Thu Feb 6 21:37:50 CET 2025


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 using 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 using 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.



More information about the R-help mailing list