Doesn't Julia automatically delete the source code of a package?

Why can I still find the source code of a package named xxx in the directory C:\Users\name\.julia\packages after running rm xxx to delete the package in Julia’s package management mode? Doesn’t Julia automatically delete it? Also, why are the source codes of the old version still retained after running update xxx to upgrade a package?

There might be multiple environments or projects using the same package source, so removing it from one environment doesn’t mean that it’s unused. You can use the gc command to garbage collect (delete) any completely unused packages.

6 Likes

Julia will automatically run gc on a periodic basis but I can’t remember how often that is.

2 Likes

I see. Thank you!

By the way, does each version of Julia (installer or portable version) always place package source files under the directory C:\Users\name\.julia\packages?

What I meant to say was, why doesn’t the portable version place the package source files in its own root directory to facilitate cross-platform use?

You can change where Julia places files via the environment variable JULIA_DEPOT_PATH or the variable DEPOT_PATH within Julia.

1 Like

I don’t use environments and also see multiple versions of a packages and that are not removed with rm nor by gc. And if we are using master versions of a package the number of sources is even larger.

1 Like

The three stages of cleanup are

  1. gc
  2. gc --all
  3. GitHub - giordano/PkgCleanup.jl: Cleanup unused Julia environments and artifacts
2 Likes

I’ve no idea about the portable version, but you can control where packages are stored using the JULIA_DEPOT_PATH environment variable.

1 Like