Only download sources of a package and all dependencies
There are now better options for this in the tools package that comes with base R: package_dependencies()
. See for example, the Answer from @sebastian-c and this recent Q&A for a related use-case.
There is an unexported getDependencies()
function in the utils package. I haven't studied how it works, but combining that with @Dirk's Answer should get you most of the way there.
Basically though, it appears you use it like:
utils:::getDependencies(pkgs, dependencies, available, lib)
where pkgs
is the character vector of packages to install, dependencies
is a character vector of types of dependencies (Depends, Enhances etc) that you want, available
is the output from available.packages()
and lib
is the library location for the packages within which dependencies are evaluated.
If you debug install.packages()
it is basically doing the getDependencies()
step then @Dirk's download.packages()
step before it actually starts installing anything.
How to download all dependencies and packages to directory
# aptitude clean
# aptitude --download-only install <your_package_here>
# cp /var/cache/apt/archives/*.deb <your_directory_here>
Offline installation of a list of packages: getting dependencies in order
The package miniCRAN
can help with this. You tell miniCRAN
the list of packages you would ever want to install, it then figures out the dependencies, downloads those packages and creates a repository on your local machine that behaves like CRAN, i.e. it respects install.packages()
etc.
More information:
Available on CRAN
Read the vignette
We are actively developing
miniCRAN
. Track progress and find the latest development version at github miniCRAN repositorySee the project wiki for links to presentations, blog posts and more
To install from the local miniCRAN
repository, you have two options.
Firstly, you can use the URI convention
file:///
. e.g.install.packages("ggplot2", repos="file:///path/to/file/")
Alternatively, you can configure the destination as an HTTP server and make your repository available via a URL. In this case, your local repository will look and feel exactly like a CRAN mirror, other than it only contains your desired packages.
What is the command line equivalent for Intellij Download sources option?
You can set the includeArtifactIds
property of maven dependency plugin to donwload only one jar:
mvn dependency:sources -DincludeArtifactIds=commons-lang3
You cannot download a single class at a time. When you use "Download sources" in IntelliJ, it downloads the complete sources for that jar.
There are more options for dependency:sources, see https://maven.apache.org/plugins/maven-dependency-plugin/sources-mojo.html.
Is there a new solution for downloading package and dependencies for a given R version
I'm not sure if it completely addresses your needs, but package checkpoint
seems appropriate here. It allows you to download source packages from a snapshot of CRAN taken at a specified date, going back to 2014-09-17
. R 4.0.0 was released around 2020-04-24
, so the snapshot from 2020-04-01
should work for your purposes.
Here is a reproducible example:
tmp1 <- tempfile()
dir.create(tmp1)
cwd <- setwd(tmp1)
getOption("repos")
## CRAN
## "https://cloud.r-project.org/"
available.packages()[c("lattice", "Matrix", "nlme"), c("Version", "Repository")]
## Version Repository
## lattice "0.20-45" "https://cloud.r-project.org/src/contrib"
## Matrix "1.4-0" "https://cloud.r-project.org/src/contrib"
## nlme "3.1-155" "https://cloud.r-project.org/src/contrib"
download.packages("Matrix", ".", type = "source")
## trying URL 'https://cloud.r-project.org/src/contrib/Matrix_1.4-0.tar.gz'
## Content type 'application/x-gzip' length 2849865 bytes (2.7 MB)
## ==================================================
## downloaded 2.7 MB
##
## [,1] [,2]
## [1,] "Matrix" "./Matrix_1.4-0.tar.gz"
tmp2 <- tempfile()
dir.create(tmp2)
checkpoint::checkpoint(snapshot_date = "2020-04-01",
r_version = "3.6.3",
checkpoint_location = tmp2,
scan_now = FALSE)
## Creating checkpoint directory /var/folders/n7/v9s56rmd5hn17d3f1qj13l7m0000gn/T//RtmpbrT5Br/filee2045e35c290/.checkpoint/2020-04-01/lib/aarch64-apple-darwin20/3.6.3
## Using checkpoint directory /private/var/folders/n7/v9s56rmd5hn17d3f1qj13l7m0000gn/T/RtmpbrT5Br/filee2045e35c290/.checkpoint/2020-04-01/lib/aarch64-apple-darwin20/3.6.3
## Warning messages:
## 1: In create_checkpoint(snapshot_date, r_version, checkpoint_location, :
## Specified R version not the same as current R version
## 2: In use_checkpoint(snapshot_date, r_version, checkpoint_location, :
## Specified R version not the same as current R version
getOption("repos")
## CRAN
## "https://mran.microsoft.com/snapshot/2020-04-01"
available.packages()[c("lattice", "Matrix", "nlme"), c("Version", "Repository")]
## Version Repository
## lattice "0.20-40" "https://mran.microsoft.com/snapshot/2020-04-01/src/contrib"
## Matrix "1.2-18" "https://mran.microsoft.com/snapshot/2020-04-01/src/contrib"
## nlme "3.1-145" "https://mran.microsoft.com/snapshot/2020-04-01/src/contrib"
download.packages("Matrix", ".", type = "source")
## trying URL 'https://mran.microsoft.com/snapshot/2020-04-01/src/contrib/Matrix_1.2-18.tar.gz'
## Content type 'application/octet-stream' length 1871705 bytes (1.8 MB)
## ==================================================
## downloaded 1.8 MB
##
## [,1] [,2]
## [1,] "Matrix" "./Matrix_1.2-18.tar.gz"
setwd(cwd)
unlink(c(tmp1, tmp2), recursive = TRUE)
The warnings about version mismatch occur if you are not actually running R 3.6.3. They can be ignored if you are only downloading source packages, with the intention of installing them on another machine actually running 3.6.3.
You can take a look at the package README
and ?checkpoint
for more details.
Update
If you are trying to download binary packages (.zip
for Windows, .tgz
for macOS) rather than source packages (.tar.gz
), then checkpoint
can get you into trouble. By default, download.packages
and friends use contrib.url(repos, type)
to construct a URL to search for package binaries.
contrib.url("https://mran.microsoft.com/snapshot/2020-04-01/src/contrib", "win.binary")
## [1] "https://mran.microsoft.com/snapshot/2020-04-01/bin/windows/contrib/4.1"
contrib.url("https://mran.microsoft.com/snapshot/2020-04-01/src/contrib", "mac.binary")
## [1] "https://mran.microsoft.com/snapshot/2020-04-01/bin/macosx/contrib/4.1"
But there is nothing at either URL. That is (in part) because contrib.url
appends the R version that you are currently running, which might not have existed on your snapshot date. Hence:
download.packages("Matrix", ".", type = "win.binary")
## Warning: unable to access index for repository https://mran.microsoft.com/snapshot/2020-04-01/bin/windows/contrib/4.1:
## cannot open URL 'https://mran.microsoft.com/snapshot/2020-04-01/bin/windows/contrib/4.1/PACKAGES'
## Warning in download.packages("Matrix", ".", type = "win.binary") :
## no package 'Matrix' at the repositories
## [,1] [,2]
download.packages("Matrix", ".", type = "mac.binary")
## Warning: unable to access index for repository https://mran.microsoft.com/snapshot/2020-04-01/bin/macosx/contrib/4.1:
## cannot open URL 'https://mran.microsoft.com/snapshot/2020-04-01/bin/macosx/contrib/4.1/PACKAGES'
## Warning in download.packages("Matrix", ".", type = "mac.binary") :
## no package 'Matrix' at the repositories
## [,1] [,2]
The URLs that you actually need are:
## Windows
"https://cran.microsoft.com/snapshot/2020-04-01/bin/windows/contrib/3.6"
## macOS, OS X, whatever
"https://cran.microsoft.com/snapshot/2020-04-01/bin/macosx/el-capitan/contrib/3.6"
The best way forward, in this case, may be to avoid checkpoint
altogether and directly pass the valid URL to available.packages
and download.packages
:
pkg <- "tidyquant"
contriburl <- "https://cran.microsoft.com/snapshot/2020-04-01/bin/windows/contrib/3.6"
db <- available.packages(contriburl)
deps <- tools::package_dependencies(pkg, db, recursive = TRUE)[[pkg]]
download.packages(c(pkg, deps), ".", contriburl = contriburl, type = "win.binary")
R: how to download the zip binaries and all the dependencies of a list of packages for an offline installation on another machine?
Use the Packrat R package; it has a bundle
method which packs up all the packages (and their dependencies), and an unbundle
method which unpacks them onto the target machine. They go into a private library, too, so they won't stomp on other libraries on your machine.
More here: https://rstudio.github.io/packrat/
Once you've installed Packrat, type ?packrat::bundle
for further instructions.
Download doc for only one Maven dependency in IntelliJ
1) Downloading individual documentation and sources:
From the maven tool window, expand the dependencies, and select the desired one, then right click it and chose your option. Although the menu item description which IJ displays in the lower left corner of the IDE reads Downloads xxx for AL DEPENDENCIES for selected projects
, it seems to download the details just for the selected libraries. Maybe it's just a reused description or menu?!
P.S. If I'm not mistaking, at one time, it was also possible to download missing docs from the docs popup window (default on win CTRL + Q), but I can no longer see it... I'll come back to this if I manage to find it.
2) Figuring out what libraries have downloaded docs a/o sources:
Go to File
-> Project structure
(default on Win is CTRL + ALT + SHIFT + S) -> Libraries
. Alternatively from the project tool window select a dependency and press F4 (or Right click -> Open library settings).
As you and browse through the list, you'll see that those that already have the documentation a/o sources have a regular coloured font...
... while those that don't, are coloured in red:
3) Download decompiled class sources:
Related Topics
How to Deal with "Data of Class Uneval" Error from Ggplot2
Emoticons in Twitter Sentiment Analysis in R
How to Convert Data Frame to Spatial Coordinates
How to Maintain Size of Ggplot with Long Labels
Dplyr Issues When Using Group_By(Multiple Variables)
Using Parallel's Parlapply: Unable to Access Variables Within Parallel Code
How to Disable "Save Workspace Image" Prompt in R
Grid of Multiple Ggplot2 Plots Which Have Been Made in a for Loop
Can Sweave Produce Many PDFs Automatically
Ggplot2: Adjust the Symbol Size in Legends
Replace All Values in a Matrix <0.1 with 0
Removing Multiple Columns from R Data.Table with Parameter for Columns to Remove
How to Add a Factor Column to Dataframe Based on a Conditional Statement from Another Column
R Fuzzy String Match to Return Specific Column Based on Matched String