# What is a package key? and is there any fundamental difference between a registered package and a self-written package?

**URL:** <https://discourse.julialang.org/t/what-is-a-package-key-and-is-there-any-fundamental-difference-between-a-registered-package-and-a-self-written-package/28473>\
**Category:** General Usage\
**Created:** [September 6, 2019, 3:28pm UTC](https://discourse.julialang.org/t/what-is-a-package-key-and-is-there-any-fundamental-difference-between-a-registered-package-and-a-self-written-package/28473 "2019-09-06T15:28:23Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [September 6, 2019, 3:28pm UTC](https://discourse.julialang.org/t/what-is-a-package-key-and-is-there-any-fundamental-difference-between-a-registered-package-and-a-self-written-package/28473/1 "2019-09-06T15:28:23Z")

</div>

I’m working on a project coding in which I need to use a Julia package downloaded from the internet. I’m not totally satisfied with the package, so some part of it needs to be changed / updated. So, I basically copy and paste their code and combine it to my original code. When I was trying to run it, I got a KeyError: Key \*\*\*\*\* [86cd37e6-c0ff-550b-95fe-21d72c8d4fc9] not found. It is rather strange. On the other hand, when I tried the same code by using the registered package through Julia keyword “using \*\*\*\*\*”, it worked out well. So, I was wondering, could anyone please explain to me, what is exactly the meaning of “KeyError: Key \*\*\*\*\* not found”? Any comments are greatly appreciated.

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [September 6, 2019, 4:21pm UTC](https://discourse.julialang.org/t/what-is-a-package-key-and-is-there-any-fundamental-difference-between-a-registered-package-and-a-self-written-package/28473/2 "2019-09-06T16:21:49Z")

</div>

If you need to edit a package, use Pkg with the develop option This will clone the package and put the source in a directory locally for you.  
[https://docs.julialang.org/en/v1/stdlib/Pkg/index.html](https://docs.julialang.org/en/v1/stdlib/Pkg/index.html)

Say we are working on `Example` and feel it needs new functionality. How can we modify the source code? We can use `develop` to set up a git clone of the `Example` package.

```julia
(tutorial) pkg> develop --local Example
...

(tutorial) pkg> status
    Status `/tmp/tutorial/Project.toml`
  [7876af07] Example v0.5.1+ [`dev/Example`]

```

---

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [September 6, 2019, 5:15pm UTC](https://discourse.julialang.org/t/what-is-a-package-key-and-is-there-any-fundamental-difference-between-a-registered-package-and-a-self-written-package/28473/3 "2019-09-06T17:15:20Z")

</div>

Here is what I did,

```julia
(v1.0) pkg> develop --local OpenStreetMapX
     Cloning git-repo `https://github.com/pszufe/OpenStreetMapX.jl.qit`
     Updating git-repo `https://github.com/pszufe/OpenStreetMapX.jl.qit`
     Resolving package versions...
     Updating `~/.julia/environments/v1.0/Project.toml`
     [86cd37e6] ? OpenStreetMapX v0.1.11 [`dev/OpenStreetMapX`]
     Updating `~/.julia/environments/v1.0/Manifest.toml`
     [86cd37e6] ? OpenStreetMapX v0.1.11 [`dev/OpenStreetMapX`]

```

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [September 6, 2019, 5:19pm UTC](https://discourse.julialang.org/t/what-is-a-package-key-and-is-there-any-fundamental-difference-between-a-registered-package-and-a-self-written-package/28473/4 "2019-09-06T17:19:47Z")

</div>

I think a bit more information on your setup would help.

So you `dev --local` the package in the Julia main environment. You could have skipped the `local` switch in that case. It is meant to make a copy inside a project environment (to be used in that project only).

The question is then: How did you bring the package into scope in the code that you are developing (your “own code”)? If that code lives in a package, it won’t be able to see the `dev`ed package (b/c it is added as a dependency to the main environment).

You need to `dev` (or `dev local`) the package in the project’s environment. Then using should not raise errors.

---

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [September 6, 2019, 5:30pm UTC](https://discourse.julialang.org/t/what-is-a-package-key-and-is-there-any-fundamental-difference-between-a-registered-package-and-a-self-written-package/28473/5 "2019-09-06T17:30:08Z")

</div>

What do you mean by `dev` (or `dev local` ) the package in the project’s environment?

---

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [September 6, 2019, 5:53pm UTC](https://discourse.julialang.org/t/what-is-a-package-key-and-is-there-any-fundamental-difference-between-a-registered-package-and-a-self-written-package/28473/6 "2019-09-06T17:53:22Z")

</div>

Now, when I run the command  
`julia> Pkg.status()`  
The row corresponding to OpenStreetMapX is like the following:  
`[86cd37e6] OpenStreetMapX v0.1.11 [`~/.julia/dev/OpenStreetMapX`]`

---

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [September 6, 2019, 5:55pm UTC](https://discourse.julialang.org/t/what-is-a-package-key-and-is-there-any-fundamental-difference-between-a-registered-package-and-a-self-written-package/28473/7 "2019-09-06T17:55:51Z")

</div>

I think I understand it now. The git clone of the Example package is now located at the path `dev/Example`?

---

<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:** [September 6, 2019, 7:07pm UTC](https://discourse.julialang.org/t/what-is-a-package-key-and-is-there-any-fundamental-difference-between-a-registered-package-and-a-self-written-package/28473/8 "2019-09-06T19:07:46Z")

</div>

Modifying the source code of a dependency is explained here: [2. Getting Started · Pkg.jl](https://julialang.github.io/Pkg.jl/v1.2/getting-started/#Modifying-A-Dependency-1)

There is no fundamental difference between registered and unregistered packages, but you do have to take care to set up your environment correctly.

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [September 7, 2019, 12:42pm UTC](https://discourse.julialang.org/t/what-is-a-package-key-and-is-there-any-fundamental-difference-between-a-registered-package-and-a-self-written-package/28473/9 "2019-09-07T12:42:41Z")

</div>

Sorry if I am explaining something that you may find obvious. But perhaps you misunderstand environments.

When you `Pkg.add` or `Pkg.dev` you are essentially editing `Project.toml` in the _current environment_.

Therefore, when you work on your code, you need to `activate` its environment before issuing the `Pkg.dev`. In the example you provided above, you edited `Project.toml` for the `v1.2` environment instead of your project environment.

I have written up what I have learned about all of this [here](https://lhendricks.org/julia_notes.pdf). Perhaps it’s helpful.
