How to completely remove a local package?

I am new to julia and I recently developed an experimental package using these procedures: generate mypackge, entered the directory, followed by activate . and dev ., and add mypackage to be able to do using mypackage and begin calling functions defined in the .jl file. All these were done by poking around and finding fractions of instructions from all over the internet. I honestly don’t know very well what these commands does.

Later I created a git repo on bitbucket, and hosted the package there without registering ( I think, I don’t know what to do to register). I did rm mypackage and verified I can no longer do using mypackage, but I can still do ‘add mypackage’, where pkg tells me that this package is identified with my local directory of mypackage. I next attempted to add the same package from bitbucket by doing add git@<url>:mypackage.jl.git, and got the following error:
ERROR: it is invalid to specify multiple packages with the same UUID: <xxxx>

I am not that surprised, but would like to know how to completely remove information about the local package and be able to install from the git repo. Can anyone help me with this?
I am also curious about what dev mypackage does? Why I cannot add the package without first doing ‘dev’?
I’m using windows 10 and Julia 1.4.2.

try ]free mypackage

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