How to give a valid uuid to an existing package and how to "desactivate" an environment?


Hello and a happy new year to everyone,

I have two simple questions concerning the basic use of Pkg. Browsing the forum I found some topics discussing those issues, but I could not really understand the answers.
I would be very happy if someone could indicate a solution to the following:

  1. I have packages that I generated using PkgDev.generate in Julia 0.6. These packages have no uuid. What is the recommended way to give them a valid uuid in julia 0.7 and higher? Should I use the new generate function (which I would like to avoid)? Or is there another way?

  2. How do I “desactivate” one of my own packages in the Pkg repl mode?
    For instance:

shell> cd /MyJuliaPackages/MyPackage/
julia> ]
(v1.0) pkg> activate .
(MyPackage) pkg>

How do I get back to the original (v1.0) environment without doing cd into the v1.0 environment?

Many thanks in advance,


I just found the answer to my second question:

shell> cd /MyJuliaPackages/MyPackage/
julia> ]
(v1.0) pkg> activate .
(MyPackage) pkg>
(MyPackage) pkg> activate
(v1.0) pkg>

Still looking for an answer to my first question.


Pkg has a built in generate command you can use which gives the project a uuid. For example, you can do pkg> generate MyPackage which will create a ./MyPackage directory. ./MyPackage/Project.toml will have a UUID. This is the recommended way to start a new project.

You can also manually create your own UUID:

import UUIDs

You might also want to read the quick guide for Pkg. Or perhaps even the full manual.


Thanks for your help and the links.

Actually, I found the answers to my question in a previous answer of yours in this post.

That was really helpful.

Thanks again


If you’re planning on registering the package any time soon, you need to use this utility function to generate a METADATA-compatible UUID:

julia> import Pkg

julia> Pkg.METADATA_compatible_uuid("MyPkg")

If you’re not planning on registering it (in the near future) then you can generate a random UUID using one of the UUID-generating functions. I recommend uuid4 to generate a random UUID:

julia> uuid4()

The uuid1 function is time-based, which seems less safe than a fully random UUID.


Huh, I wasn’t aware of that function. Thanks for clarifying :smile: