How do I remove all my installed packages at once, if possible?

When I first started Julia I installed a Lot of packages to try. Now I have two pagefulls with conflicts and it’s hard to figure out which pkg is the cause. I’d like to just delete the lot and reinstall the few I’ve found useful for now. Is there a way to do that?

delete ~/.julia/environments/v1.x, x can be 6 or 7 depending on what you have. Note this won’t delete the packages’ source code, just the Manifest.toml that records your environment, so when you re install some packages, you won’t have to re download them all

1 Like

Also, this is a good occasion to learn to use local environments, instead of polluting the global one, which should really be as small as possible :slightly_smiling_face:

BTW, a relatively unknown trick is to do

]activate --temp

to create a temporary one-off environment that will be automatically deleted at the end of the Julia session. It’s very useful to quickly try out some packages

13 Likes

delete ~/.julia/environments/v1.x , x

Doing this can break your startup.jl file, so you might want to rename it before you do this. Otherwise Julia will fail to start the REPL and you’ll have to deal with startup.jl anyhow.

My startup.jl file has lots of things like using Revise in it, for example.

The recommended configuration for Revise suggests putting using Revise in a try/catch block. Not relying on the global environment having third-party packages installed is good.

2 Likes

you can always get around the first time by

julia --startup-file=no

since we’re talking about deleting and reinstalling… this shouldn’t be too much on top of the hassle

2 Likes

Correct me if I’m wrong. But one thing I find annoying about local environments is that adding a package in the environment may cause it to be updated. Sometimes this triggers precompilation of many packages. It is not the same as just use a package that is already there.

2 Likes

As far as I know, local and global environments are no different in this regard: by default adding a package triggers an update (maybe only the first time in a session) and precompilation of all packages in the environment (that’d be way less than having everything in a single global environment).

If you’re annoyed by precompilation, there is a trick to not update packages on add, it has been shared a few times here on discourse, many people put that code in their startup file

3 Likes

I have never regretted deleting my .julia folder entirely and reinstalling everything from scratch. It is shockingly fast these days.

But as I think other people have said, if your global environment is getting mucked up, then it is almost certainly because you aren’t using project/manifest files sufficiently. The only things I have in my global environment is IJulia, Revise, and BenchmarkTools and the occasional others.

3 Likes

this: How to disable automatic precompilation of packages in Julia 1.6

Yes, you’re right. It is not that exactly. The annoying thing is that a package that is installed in a local environment is not available to using in the other environments (as are the packages installed in the “main” environment). Thus, either one has to install things on the “main” environment, or keep adding packages to new environments every time.

1 Like

I was talking about not updating, not not precompiling:

But I guess someone may not want to precompile (?)

2 Likes