How to deinstall a package

Thsi question is relevant to the current package manager. It there is an answer for Pkg3 this will be welcome also. The Documentation does have a section on removing packages. but it is unclear and has not worked for me in the past. Should I use Pkg.free(“packagename”) ??

I have three use cases at the momen tfor removing packages:

  • I might give a talk to colleagues. I might want to demonstrate how to install IJulia
  • I wish to develop in the ClusterManagers package - so need to remove the existing copy and substitute with the development version
  • sometimes I am convinced that a package is completely fuled up and I want to start from a clean install

I do admit that the third use case is stupid, but I have got into messes in the past with ImageView on Windows 10 and I ended up wiping Julia and starting from scratch.

1 Like

Pkg.rm is the way on Pkg2.

It is similarly used in Pkg3 except it won’t actually delete the package, it will just remove it from the project. In Pkg3 you can have multiple versions of the same package installed at the same time and different projects can use different versions.

If you want to show julia from scratch with Pkg2 you can set the JULIA_PKGDIR env variable to some folder and do Pkg.init().

5 Likes

Also, in Pkg3 you can use the pkg> gc command to delete all package versions that are no longer referred to by any projects (those found in ~/.julia/logs/manifest_usage.toml). For example, I just did this on my system:

pkg> gc
[ Info: Deleted 93 package installations saving 395.409 MiB

I suspect most people won’t have quite so many random package versions installed since I do a fair bit of messing around with installing and changing packages. The pkg> gc command isn’t yet called automatically, but we intend to set that up at some point in the future. It will also clean up old resources like obsolete .ji files.

9 Likes

rm package only removed the package in packages folder. It can not remove package in the dev folder. How can I do it?

1 Like
rm -rf ~/dev/PackageName
2 Likes

I think you mean

rm -rf ~/.julia/dev/PackageName

Your version would be quite catastrophic if someone had a dev folder in their home directory!

1 Like

That’s where I keep my dev packages. Don’t run random code some guy posts on the Internet without making sure it doesn’t do something bad :grimacing:

4 Likes

you can have a (default) dev path that is different (not under) the JULIA_DEPOT_PATH?
Or you just manually do dev /path/to/my/dev for every package you dev?

Both are possible: Pkg · The Julia Language

1 Like

after removing the package, I get some errors:

ERROR: path /usr/people/jingpeng/.julia/dev/Clustering for package Clustering no longer exists. Remove
 the package or `develop` it at a new path                                                            

I have to run
pkg > rm package to really remove it in Project.toml file.

Correct. I assumed you’d already done that since a package wouldn’t be gc’d unless it was removed from all projects already.