Reinstalling packages to clear up dependency issues

I thought I’d post this in case it’s of benefit to anyone else. i ran into an issue where I needed to purge my Packages and reinstall everything - here’s two scripts I wrote to easily drop and re-install all of your packages…

/usr/local/bin/julia ~/installed.jl > ./julia.txt && echo "updated julia packages"

where installed.jl is just

using Pkg
for (k,v) in Pkg.installed()
           println("$k:$v")
end

and

gen_reinstall.sh is:

#!/bin/sh

last=`tail -1 ~/julia.txt | awk -F: ' { print $1 } '`

cat ~/julia.txt | awk -F: 'BEGIN { printf("# DO NOT EDIT - AUTOGENERATED!!!\n"); printf("Using Pkg\n\npackages = [\n") } $1 !~/'"$last"'/{ printf("\t\"%s\",\n", $1) } $1 ~/'"$last"'/ { printf("\t\"%s\"\n", $1)} END { printf("]\n for p in packages\n\tprintln(\"attempting to add $p\")\n\tPkg.add(p)\n end") } '  > reinstall.jl

Seems like an overly complicated way to save the Project.toml and Manifest.toml.

2 Likes

These are packages that Ive installed via the REPL - I didn’t know that there are associated Project and Manifest files associated with the REPL - where would I find them?

No matter how you install packages they will be added to an environment. If you have not made an active choice you will install to the default environment located at ~/.julia/environments/v1.0.

1 Like

Thanks! learned something new today. How do you create a non-default environment?

Have a look at the documentation: https://julialang.github.io/Pkg.jl/dev/environments/#Creating-your-own-projects-1

thanks!