# Transfer module definition to worker

**URL:** <https://discourse.julialang.org/t/transfer-module-definition-to-worker/102779>\
**Category:** General Usage\
**Tags:** distributed\
**Created:** [August 14, 2023, 5:47am UTC](https://discourse.julialang.org/t/transfer-module-definition-to-worker/102779 "2023-08-14T05:47:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DrChainsaw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/drchainsaw/32/8497_2.png) [@DrChainsaw](https://discourse.julialang.org/u/DrChainsaw)\
**Post date:** [August 14, 2023, 5:47am UTC](https://discourse.julialang.org/t/transfer-module-definition-to-worker/102779/1 "2023-08-14T05:47:38Z")

</div>

Is there a way to transfer a module definition to a worker without it being defined in a file or inside an `@everywhere` expression.

For example:

```julia

# Assume this happens in a context where it would be impractical to insert an @everywhere
julia> module A
       export f
       f() = 1
       end
A

julia> using Distributed

julia> addprocs(1)
1-element Vector{Int64}:
 2

julia> @everywhere using .A
ERROR: On worker 2:
UndefVarError: `A` not defined

julia> Distributed.remotecall_eval(Main, 2, :(using $A))
ERROR: On worker 2:
UndefVarError: `A` not defined

julia> remotecall_fetch(2, A) do m
       using m
       end
ERROR: syntax: "using" expression not at top level

```

The reason why I want this has to do with interfacing with an existing tool which I don’t have the power to change.

I can probably work in the `@everywhere` before the module definition somehow if that is the only way.
