How to completely remove a local package?

Thank you but unfortunately I got
ERROR: unable to free unregistered package xxxx

]rm mypackage
]add (bitbucket link)

That’s what I did originally, first removing the package then adding the git repo. I got the error

ERROR: it is invalid to specify multiple packages with the same UUID: xxxx

as I posted. I should mention that bitbucket changed the name to all lower case while my local package name is MyPackage. I guess that’s where the “multiple packages” came from?

mv ~/.julia ~/.julia1
start julia and install packages

1 Like

Thanks but too much brute force and does not help me understand

dev and add do different things. See this answer in a recent thread (the original question was different, but may give you another perspective to understand what is happening):

A more detailed explanation of the main pkg commands here:
https://julialang.github.io/Pkg.jl/v1/managing-packages/

For your particular case, if the dev’ed version of ’ MyPackagelives in.julia/dev`, maybe it’s still finding that it is there, and there might be a conflict due to the lowercase/camelcase names, but I’m not sure.

You can try to check if that’s what is happening: if the package is in .julia/dev, move it to another place (e.g. outside .julia), and try add again. Let’ see what happens.

2 Likes

I believe that removing a package doesn’t actually delete it from ~/.julia/packages. I’d try removing it with rm -r ~/.julia/packages/<yourpackage>.

1 Like

Without knowing more about your setup and what exactly you did, it’s hard to say, but when you do ]dev SomePackage, that package gets cloned to your system (usually in ~/.julia/dev) and then the package manager will not touch it, ever. Things like ]free SomePackage and ]rm SomePackage will free/remove the reference from your environment, but will not delete the folder.

I’m not sure why you’re getting the UUID collision, unless you changed the name of the package (in the Project.toml or something) without changing the UUID.

My suggestions:

  1. use git to your advantage. If you’ve got a locally dev'd version, use git to update it / change it. Git allows you to have multiple remotes, multiple branches etc.
  2. Double check in your ~/.julia/dev directory that your old version is not still lying around. If it is, and you don’t want to delete it, you can always change the UUID (it’s set in the Project.toml, and you can get a new one with using UUIDs; uuid4()
2 Likes

Just to be sure: you restarted Julia after removing the package?

1 Like

Oh, yes, that might be also the case. But I don’t like tinkering with the contents of .julia/packages myself. If the add-ed version was removed and not used in any environment anymore, ]gc should do the same in a safe manner, I think.

There is no problem having multiple versions of a package stored on your computer somewhere. It happens all the time because you can use multiple versions in different environments.

It would help to see the Project.toml / Manifest.toml for the environment where you are trying to add.

3 Likes

Actually:

1 Like

Yeah - but I thought that the relevant name would be the one found in Project.toml, not the directory name

Yeah, this is a really annoying “feature” of Bitbucket. I recommend GitHub and/or GitLab instead. Of course, if you are required to use Bitbucket by your organization, that doesn’t help you much.

2 Likes

I’m not using Bitbucket so I don’t know, but maybe it’s not only the directory name, but also the name of the source files (e.g. src/MyPackage.jl > src/mypackage.jl)?

Anyway, to address the initial question, sometimes it can be hard to debug these Pkg problems. @ppalmes’s answer is a reliable way to fix these things.

Thanks for your response. Somehow even though I deved my package, my ~/.julia/ folder does not contain a dev folder, which may be strange. The difference in the upper/lower cases of the repo name and package name (.jl file name and module name) may not really matter, but I attempted the following

]add “git@bitbucket.com:xxxx/mypackage.jl.git” “MyPackage”

following some online instruction which seems to be outdated. I later did the following: restart REPL, ]rm MyPackage, delete the ~/.julia/packages/MyPackage/ folder, restart again and do

]add “git@bitbucket.com:xxxx/mypackage.jl.git”

to make it work. I don’t know which step is critical though, but I’m glad it got resolved.

if you want to understand what went wrong, add similar packages including yourpackage with the new .julia and diff .julia .julia1 to see which part causes the duplication issue.

3 Likes

Thank you all. I marked kevbonham’s answer as solution but obviously all of you are of great help :wink:

1 Like

If you first created the package in, say, ~/Desktop/MyPackage, and then did ]dev ~/Desktop/MyPackage, julia will just point directly to that repo. I’m not sure if Pkg is smart enough to remember all the paths to deved packages in all of your manifests, but it would not surprise me if it was.

I tend to think of packages that are deved and those that are added in completely different buckets. The former are just git repos that julia knows about, and never messes with. The later I treat as black boxes that I only modify with Pkg.

3 Likes