# Method definition overwritten warnings when compiling cache or "using module" twice

**URL:** <https://discourse.julialang.org/t/method-definition-overwritten-warnings-when-compiling-cache-or-using-module-twice/28970>\
**Category:** General Usage\
**Created:** [September 19, 2019, 9:20pm UTC](https://discourse.julialang.org/t/method-definition-overwritten-warnings-when-compiling-cache-or-using-module-twice/28970 "2019-09-19T21:20:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rwgardner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rwgardner/32/10344_2.png) [@rwgardner](https://discourse.julialang.org/u/rwgardner)\
**Post date:** [September 19, 2019, 9:20pm UTC](https://discourse.julialang.org/t/method-definition-overwritten-warnings-when-compiling-cache-or-using-module-twice/28970/1 "2019-09-19T21:20:32Z")

</div>

I have some code with this general structure

```julia
push!(LOAD_PATH, Base.source_dir())                                                                                                     
                                                                                                                                        
Base.compilecache(Base.PkgId("Mod1"))                                                                                                   
                                                                                                                                        
using Mod1                                                                                                                              
using Mod2                                                                                                                              
                                                                                                                                        
Mod2.bar(5)

```

where Mod2.jl also has

```julia
using Mod1

```

When I do this, I get a large number of “WARNING: Method definition \_\_ overwritten…” for methods that are indeed in Mod1.

First, I get these warnings from the compilecache call (which is not there to be useful so much as to figure out what’s going on). Then I get them again for the “using Mod1” in Mod2.

I don’t get warnings for all the methods in Mod1 though, probably only about 1-2% of them, actually. I can’t see anything that is special about those methods.

I’d give a complete replicable example, but I haven’t been able to create one. My Mod1 is huge, with more than 10,000 lines of code. For simple Mod1 equivalents, I don’t get any warnings (which is consistent with how I only get warnings for a small portion of the functions).

If I put **precompile** (false) in Mod1, the warnings go away. (Similarly, they might go away if I used include instead of using to bring in the modules.) But I’d like to (a) be able to precompile and (b) understand this so I have a good workflow in Julia in the future.

Help? Thanks.

---

<div class="post-metadata">

**Author:** ![razvangheorghe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/razvangheorghe/32/12436_2.png) [@razvangheorghe](https://discourse.julialang.org/u/razvangheorghe)\
**Post date:** [February 27, 2020, 9:56pm UTC](https://discourse.julialang.org/t/method-definition-overwritten-warnings-when-compiling-cache-or-using-module-twice/28970/2 "2020-02-27T21:56:50Z")

</div>

Not sure if you still need this, but I’ve just went through something similar.

For one of my source files, let’s say file.jl, I was getting warnings for all the types and functions defined.  
The weird thing was that they said something like method (…) at file.jl:5 is overwritten at file.jl:5.

my module\_name.jl looked something like:

```julia
module module_name
        include("file1.jl")
        include("file2.jl")
end

```

and the problem was that I had include(“file1.jl”) in file2.jl and that include was overwriting the methods.
