Efficient Way of Installing Packages

Hey everyone,

while learning R I came across a forum post that was very helpful for checking and installing what packages were missing for a user. The R code went like this:

packages <- c("package names"...)

# Install packages not yet installed
installed_packages <- packages %in% rownames(installed.packages())
if (any(installed_packages == FALSE)) {
  install.packages(packages[!installed_packages])
}

# Packages loading
invisible(lapply(packages, library, character.only = TRUE))

Does anyone have any tips on how I could do this in julia?

Thanks in advance for any help!

“efficient” eh? In Julia you just press ] at REPL and type add X1, X2.... If you’re trying to share your environment, simply send them your Project.toml file (or for exact reproduction, Manifest.toml file) and (again, press ] first)

pkg> activate .
pkg> instantiate
2 Likes

Or I guess, the functional way would also work (didn’t try this):

using Pkg
packages = ["package A", "package B", ...]
Pkg.add.(packages)

pretty sure Pkg.add takes a vector of string already

even better