# Why do I have to specify the name of the module when code is included in remote processes?

**URL:** <https://discourse.julialang.org/t/why-do-i-have-to-specify-the-name-of-the-module-when-code-is-included-in-remote-processes/84756>\
**Category:** General Usage\
**Tags:** module, distributed\
**Created:** [July 25, 2022, 1:57pm UTC](https://discourse.julialang.org/t/why-do-i-have-to-specify-the-name-of-the-module-when-code-is-included-in-remote-processes/84756 "2022-07-25T13:57:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zekeriya.sari](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zekeriya.sari/32/13695_2.png) [@zekeriya.sari](https://discourse.julialang.org/u/zekeriya.sari)\
**Post date:** [July 25, 2022, 1:57pm UTC](https://discourse.julialang.org/t/why-do-i-have-to-specify-the-name-of-the-module-when-code-is-included-in-remote-processes/84756/1 "2022-07-25T13:57:08Z")

</div>

Hi

Consider the following two files `test.jl` and `temp.jl` with the following content

```julia
# test.jl file 

module Foo

using Distributed
function baz()
    addprocs(2)
    @everywhere include("temp.jl")
    for worker in workers()
        remotecall_fetch(println, worker, bar)
    end
end

function baz2()
    addprocs(2)
    @everywhere include("temp.jl")
    for worker in workers()
        remotecall_fetch(println, worker, Main.bar)
    end
end

end # module 

```

```julia
# temp.jl
bar(x) = 2x

```

When I run the following

```julia
julia> import .Foo

julia> using Distributed

julia> @fetchfrom workers()[1] InteractiveUtils.varinfo() # bar is in varinfo
  name size summary                             
  ––––––––––– ––––––––– ––––––––––––––––––––––––––––––––––––
  Base Module                              
  Core Module                              
  Distributed 1.079 MiB Module                              
  Main Module                              
  bar 0 bytes bar (generic function with 1 method)

```

I see that `bar` is loaded in the worker process. While the following throws an `UndefVarError`

```julia
julia> Foo.baz() 
ERROR: UndefVarError: bar not defined
Stacktrace:
 [1] baz()
   @ Main.Foo ~/.julia/dev/DynamicalNetworks/ClusterShiftKeyinChaosCommunication/test.jl:22
 [2] top-level scope
   @ REPL[1]:1

```

the following throws no error.

```julia
julia> Foo.baz2()
      From worker 2: bar
      From worker 3: bar
      From worker 4: bar
      From worker 5: bar
      From worker 6: bar
      From worker 7: bar

```

Thus, it seems that `bar` cannot be used without specifying the module name `Main` explicitly. I understand that `bar` is bound to module `Main`. But, why do I have to specify it when I try to reach the bound function `bar`?

Moreover, if I define function not inside of a module, the prefix `Main` is not required again as shown below. I could not get why. Any help is appreciated.

```julia
julia> function baz3()
           addprocs(2)
           @everywhere include("temp.jl")
           for worker in workers()
               remotecall_fetch(println, worker, bar)
           end
       end
baz3 (generic function with 1 method)

julia> baz3()
      From worker 2: bar
      From worker 3: bar
      From worker 4: bar
      From worker 5: bar
      From worker 6: bar

```
