# Error in example code for "global binding during remote execution" in Julia doc

**URL:** <https://discourse.julialang.org/t/error-in-example-code-for-global-binding-during-remote-execution-in-julia-doc/32502>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [December 20, 2019, 7:54am UTC](https://discourse.julialang.org/t/error-in-example-code-for-global-binding-during-remote-execution-in-julia-doc/32502 "2019-12-20T07:54:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sijun](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Sijun](https://discourse.julialang.org/u/Sijun)\
**Post date:** [December 20, 2019, 7:54am UTC](https://discourse.julialang.org/t/error-in-example-code-for-global-binding-during-remote-execution-in-julia-doc/32502/1 "2019-12-20T07:54:56Z")

</div>

In section title **What are the possible causes of an UndefVarError during remote execution?** in page 427 Julia 1.3.0 doc pdf, there is the following code example:

```julia
@everywhere module Foo
    function foo()      
        global gvar = "Hello"  
        remotecall_fetch(() -> gvar, 2)
    end
end

```

To fix the intentional bug and make the code work, I had to introduces two fixes:

```julia
@everywhere module Foo
    using Distributed
    gvar = "Hello"
    function foo()        
        remotecall_fetch(() -> gvar, 2)
    end
end

```

1. `using Distributed` added to the module `Foo`
2. `gvar` is put in module global from the beginning

Here I wonder why `using Distributed` had to be added to the module `Foo` because I already ran `using Distributed` outside of module `Foo` before I do `@everywhere module Foo`, thereby having made the remote processes ready for using `Distributed` far before `Foo` was defined.
