# About WARNING: replacing module on @everywhere include

**URL:** <https://discourse.julialang.org/t/about-warning-replacing-module-on-everywhere-include/8881>\
**Category:** General Usage\
**Tags:** question\
**Created:** [February 7, 2018, 3:20am UTC](https://discourse.julialang.org/t/about-warning-replacing-module-on-everywhere-include/8881 "2018-02-07T03:20:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paalon/32/5784_2.png) [@paalon](https://discourse.julialang.org/u/paalon)\
**Post date:** [February 7, 2018, 3:20am UTC](https://discourse.julialang.org/t/about-warning-replacing-module-on-everywhere-include/8881/1 "2018-02-07T03:20:02Z")

</div>

I have a question about warnings when I tried to use `@everywhere include`.

```julia
# ParallelTest.jl

module ParallelTest

include("MyModule.jl")
using Distributions

export loop

function hello()
    println("Hello")
end

function loop()
    @sync @parallel for i = 1:10
        n = MyModule.f(rand(Uniform(0.0, 1.0)))
        println(n)
        hello()
    end
end

println("loaded")

end

```

```nohighlight
#MyModule.jl

module MyModule

export f

f(x) = 1000x

end

```

I have these files and on REPL,

```julia
> julia
               _
   _ _ _(_)_ | A fresh approach to technical computing
  (_) | (_) (_) | Documentation: https://docs.julialang.org
   _ _ _| |_ __ _ | Type "?help" for help.
  | | | | | | |/ _` | |
  | | |_| | | | (_| | | Version 0.6.2 (2017-12-13 18:08 UTC)
 _/ |\ __'_|_|_|\__'_| | Official http://julialang.org/ release
|__/ | x86_64-apple-darwin14.5.0

julia> addprocs(Sys.CPU_CORES)
4-element Array{Int64,1}:
 2
 3
 4
 5

julia> @everywhere include("ParallelTest.jl")
loaded
WARNING: replacing module Distributions.
WARNING: replacing module Distributions.
WARNING: replacing module Distributions.
WARNING: replacing module Distributions.
	From worker 5:	loaded
	From worker 4:	loaded
	From worker 2:	loaded
	From worker 3:	loaded

julia> using ParallelTest

julia> loop()
	From worker 3:	248.26250919968572
	From worker 3:	Hello
	From worker 3:	675.4954509960418
	From worker 3:	Hello
	From worker 3:	662.744163133056
	From worker 3:	Hello
	From worker 5:	506.503005053337
	From worker 5:	Hello
	From worker 5:	935.7835204817176
	From worker 5:	Hello
	From worker 4:	75.66083075524399
	From worker 4:	Hello
	From worker 4:	528.1776227635611
	From worker 4:	Hello
	From worker 2:	62.40940261002525
	From worker 2:	Hello
	From worker 2:	382.29946951026574
	From worker 2:	Hello
	From worker 2:	164.9343457703678
	From worker 2:	Hello
4-element Array{Future,1}:
 Future(2, 1, 14, #NULL)
 Future(3, 1, 15, #NULL)
 Future(4, 1, 16, #NULL)
 Future(5, 1, 17, #NULL)

```

Why I get the `WARNING: replacing module Distributions.`?

---

<div class="post-metadata">

**Author:** ![hsgg](https://avatars.discourse-cdn.com/v4/letter/h/838e76/32.png) [@hsgg](https://discourse.julialang.org/u/hsgg)\
**Post date:** [May 29, 2018, 1:55am UTC](https://discourse.julialang.org/t/about-warning-replacing-module-on-everywhere-include/8881/2 "2018-05-29T01:55:32Z")

</div>

I have basically the same question. Though, if you look at the [manual](https://docs.julialang.org/en/stable/manual/parallel-computing/#Code-Availability-and-Loading-Packages-1), I think the answer is that when you call `using Distributions` on one process, then the module `Distributions` is loaded on all processes. Hence, every process causes a reload on every other process.

A simpler example is the following code:

```julia
addprocs(2)
@everywhere module MyModule
using Distributions
end

```

which results in

```julia
julia> addprocs(2)
2-element Array{Int64,1}:
 2
 3

julia> @everywhere module MyModule
       using Distributions
       end
WARNING: replacing module Distributions.
WARNING: replacing module Distributions.

```

I use this programming style all the time, and would love to hear of a solution!

EDIT: fix link

---

<div class="post-metadata">

**Author:** ![greg\_plowman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/greg_plowman/32/8100_2.png) [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Post date:** [May 29, 2018, 2:42am UTC](https://discourse.julialang.org/t/about-warning-replacing-module-on-everywhere-include/8881/3 "2018-05-29T02:42:41Z")

</div>

I don’t have a solution for modules defined at the REPL, but you shouldn’t need `@everywhere` for modules in your `LOAD_PATH`.

Create file `MyModule.jl` with the following:

```julia
module MyModule
    using Distributions
end

```

Place this file in one of the directories in your `LOAD_PATH`:  
`load_path_directory/MyModule/src/MyModule.jl`

At the REPL, type the following to load `MyModule` on all processes.

```julia
addprocs()
using MyModule

```

Note that `@everywhere` should not be necessary.
