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

**URL:** <https://discourse.julialang.org/t/how-to-give-a-valid-uuid-to-an-existing-package-and-how-to-desactivate-an-environment/19236>\
**Category:** New to Julia\
**Created:** [January 3, 2019, 3:14pm UTC](https://discourse.julialang.org/t/how-to-give-a-valid-uuid-to-an-existing-package-and-how-to-desactivate-an-environment/19236 "2019-01-03T15:14:53Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Olivier\_Merchiers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/olivier_merchiers/32/4073_2.png) [@Olivier\_Merchiers](https://discourse.julialang.org/u/Olivier_Merchiers)\
**Post date:** [January 3, 2019, 3:14pm UTC](https://discourse.julialang.org/t/how-to-give-a-valid-uuid-to-an-existing-package-and-how-to-desactivate-an-environment/19236/1 "2019-01-03T15:14:54Z")

</div>

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:

```julia
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,  
Olivier

---

<div class="post-metadata">

**Author:** ![Olivier\_Merchiers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/olivier_merchiers/32/4073_2.png) [@Olivier\_Merchiers](https://discourse.julialang.org/u/Olivier_Merchiers)\
**Post date:** [January 3, 2019, 4:08pm UTC](https://discourse.julialang.org/t/how-to-give-a-valid-uuid-to-an-existing-package-and-how-to-desactivate-an-environment/19236/2 "2019-01-03T16:08:07Z")

</div>

I just found the answer to my second question:

```julia
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.

---

<div class="post-metadata">

**Author:** ![00vareladavid](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00vareladavid/32/23521_2.png) [@00vareladavid](https://discourse.julialang.org/u/00vareladavid)\
**Post date:** [January 4, 2019, 7:38am UTC](https://discourse.julialang.org/t/how-to-give-a-valid-uuid-to-an-existing-package-and-how-to-desactivate-an-environment/19236/3 "2019-01-04T07:38:38Z")

</div>

`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:

```julia
import UUIDs
UUIDs.uuid1()

```

You might also want to read the [quick guide](https://julialang.github.io/Pkg.jl/dev/getting-started/) for `Pkg`. Or perhaps even the [full manual](https://julialang.github.io/Pkg.jl/v1/).

---

<div class="post-metadata">

**Author:** ![Olivier\_Merchiers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/olivier_merchiers/32/4073_2.png) [@Olivier\_Merchiers](https://discourse.julialang.org/u/Olivier_Merchiers)\
**Post date:** [January 4, 2019, 10:01am UTC](https://discourse.julialang.org/t/how-to-give-a-valid-uuid-to-an-existing-package-and-how-to-desactivate-an-environment/19236/4 "2019-01-04T10:01:39Z")

</div>

Thanks for your help and the links.

Actually, I found the answers to my question in a previous answer of yours in [this post](https://discourse.julialang.org/t/upgrading-a-package-to-v1-0-and-developping/17371/2).

That was really helpful.

Thanks again

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [January 4, 2019, 12:51pm UTC](https://discourse.julialang.org/t/how-to-give-a-valid-uuid-to-an-existing-package-and-how-to-desactivate-an-environment/19236/5 "2019-01-04T12:51:44Z")

</div>

**Note:** This was only necessary for packages there were registered in both the old METADATA system and the new registry system. It has not been necessary for years and the functionality described has been deleted. If you need a UUID for a new package, you can use the `UUIDs.uuid4()` function to generate a random UUID or use a package templater `Pkg.generate()` or `PkgTemplates` which will generate a random UUID for you.

* * *

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
julia> import Pkg

julia> Pkg.METADATA_compatible_uuid("MyPkg")
UUID("793ebe2b-975c-555a-bd0c-65619c3a03ab")

```

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
julia> uuid4()
UUID("d123c894-4263-439f-b244-578b071eadd5")

```

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

---

<div class="post-metadata">

**Author:** ![00vareladavid](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00vareladavid/32/23521_2.png) [@00vareladavid](https://discourse.julialang.org/u/00vareladavid)\
**Post date:** [January 4, 2019, 9:00pm UTC](https://discourse.julialang.org/t/how-to-give-a-valid-uuid-to-an-existing-package-and-how-to-desactivate-an-environment/19236/6 "2019-01-04T21:00:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Krastanov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krastanov/32/6817_2.png) [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Post date:** [December 17, 2020, 4:38pm UTC](https://discourse.julialang.org/t/how-to-give-a-valid-uuid-to-an-existing-package-and-how-to-desactivate-an-environment/19236/7 "2020-12-17T16:38:24Z")

</div>

This still pops up on google when searching for package uuids, and it seems it is outdated advice, right? `METADATA_compatible_uuid` is now removed (in this commit [https://github.com/JuliaLang/Pkg.jl/commit/5e25ac0a7cbeeeaa408fce453db3c8956876e6a2](https://github.com/JuliaLang/Pkg.jl/commit/5e25ac0a7cbeeeaa408fce453db3c8956876e6a2)) and we should just use `UUIDs.uuid4()`

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [December 17, 2020, 5:14pm UTC](https://discourse.julialang.org/t/how-to-give-a-valid-uuid-to-an-existing-package-and-how-to-desactivate-an-environment/19236/8 "2020-12-17T17:14:02Z")

</div>

Yes, this advice was only for packages that were migrating from the old METADATA registry to the new General registry and needed a consistent UUID. If you are creating a new package, you should use PkgTemplates, which generates a random UUID for you.

---

<div class="post-metadata">

**Author:** ![logankilpatrick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/logankilpatrick/32/38123_2.png) [@logankilpatrick](https://discourse.julialang.org/u/logankilpatrick)\
**Post date:** [November 12, 2021, 3:56pm UTC](https://discourse.julialang.org/t/how-to-give-a-valid-uuid-to-an-existing-package-and-how-to-desactivate-an-environment/19236/9 "2021-11-12T15:56:26Z")

</div>

The above solution is outdated and no longer works with Julia 1.6. I posted an updated question here: [How to create a UUID for a Julia Package? - Stack Overflow](https://stackoverflow.com/questions/69945658/how-to-create-a-uuid-for-a-julia-package) since this post is still the top search result.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [November 13, 2021, 3:50am UTC](https://discourse.julialang.org/t/how-to-give-a-valid-uuid-to-an-existing-package-and-how-to-desactivate-an-environment/19236/10 "2021-11-13T03:50:12Z")

</div>

It was also only ever meant for the time period before Julia 1.0 when people were registering packages in both METADATA and the new registry. There’s been a `Pkg.generate()` function that does this correctly for you and various other templates packages too. Which is exactly what I already said in my last post in 2020.

---

<div class="post-metadata">

**Author:** ![logankilpatrick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/logankilpatrick/32/38123_2.png) [@logankilpatrick](https://discourse.julialang.org/u/logankilpatrick)\
**Post date:** [November 13, 2021, 4:50am UTC](https://discourse.julialang.org/t/how-to-give-a-valid-uuid-to-an-existing-package-and-how-to-desactivate-an-environment/19236/11 "2021-11-13T04:50:52Z")

</div>

Yes, sorry, wasn’t trying to say otherwise, just wanted to leave that note as a more general comment in case someone stumbles upon the thread like I did and was only skimming through it.
