# Multiple modules in compilecache file?

**URL:** https://discourse.julialang.org/t/multiple-modules-in-compilecache-file/90406
**Category:** Internals & Design
**Tags:** question
**Created:** [November 17, 2022, 3:21pm UTC](https://discourse.julialang.org/t/multiple-modules-in-compilecache-file/90406 "2022-11-17T15:21:52Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![green.nsk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/green.nsk/32/24014_2.png) [@green.nsk](https://discourse.julialang.org/u/green.nsk)
#### Post date: [November 17, 2022, 3:21pm UTC](https://discourse.julialang.org/t/multiple-modules-in-compilecache-file/90406/1 "2022-11-17T15:21:52Z")

</div>

I was down a rabbithole trying to understand why I am getting multiple versions of a single package loaded in my application. And I think I narrowed it down to the fact that one of precompile cache files contains two “modules”. What I couldn’t figure out was why this happened and what I did wrong.

Here’s an illustration of this problem (not the actual code):

```julia
module A

end

module B

using A

end

module C

using A

end

using B
using C
# ┌ Warning: Replacing module `A`
# └ @ Base loading.jl:1036

println(pointer_from_objref(B.A))
println(pointer_from_objref(C.A))

```

I expect it to print the same pointer twice, but in fact I get different pointers. In my case A, B and C are separate packages.

My diagnostics took me to write this snippet:

```julia
function check_compilecache(pkgid)
    pkg_cache_paths = Base.find_all_in_cache_path(pkgid)
    for cachefile in pkg_cache_paths
        try
            modules = open(cachefile, "r") do io
                Base.isvalid_cache_header(io)
                Base.parse_cache_header(io)
            end[1]
            println(cachefile => modules)
        catch e
            println(cachefile => e)
        end
    end
end

```

So when I do `check_compilecache(Base.PkgId(UUID("xxxx-xxxx-xxx"), "C"))` it tells me that one of cache files has two modules: C and A. Which, I think, means that `using B` loads module A from A’s own compilecache, and `using C` loads C as well as another instance of A.

I am sorry if I missed some important detail, but I’ve kept a copy of compilecache and can probably inspect it more if anyone is kind enough to help me dig further.

This is all done running julia-1.7.2 in case it’s important
