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

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.

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.

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.

(tutorial) pkg> develop --local Example

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

Here is what I did,

(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`]

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 deved 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.


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

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]

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

Modifying the source code of a dependency is explained here: 2. Getting Started · Pkg.jl

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


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. Perhaps it’s helpful.