# Unable to create parallel package

**URL:** <https://discourse.julialang.org/t/unable-to-create-parallel-package/113207>\
**Category:** General Usage\
**Tags:** question, package, distributed\
**Created:** [April 18, 2024, 6:50pm UTC](https://discourse.julialang.org/t/unable-to-create-parallel-package/113207 "2024-04-18T18:50:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jafagervik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jafagervik/32/208594_2.png) [@jafagervik](https://discourse.julialang.org/u/jafagervik)\
**Post date:** [April 18, 2024, 6:50pm UTC](https://discourse.julialang.org/t/unable-to-create-parallel-package/113207/1 "2024-04-18T18:50:12Z")

</div>

Hi, I’m trying to make a package in which I use Distributed.jl a bit.

Lets call it Intro.jl, and I have two files in src directory. Intro.jl contains this code:

```julia
module Intro
using Distributed 

export mad, meap
include("test.jl")

end

```

test.jl contains this code:

```julia
function mad() 
    pmap(_ -> println("$(myid())", 1:10)
end

@everywhere function lerp(message)
    println("$message from $(myid())")
end

function meap()
    @sync begin
         for pid in workers()
             @async begin
                 remotecall_fetch(lerp, pid,"YO")
             end 
         end 
    end
end 

```

Now, Im able to open the REPL and run using Intro if I only use the mad function.  
However when I use @everywhere on some functions I get this error:

 ![1713466106](https://global.discourse-cdn.com/julialang/original/3X/3/e/3e822125fb421144ba150aa71ee4bc009fdcf248.png)

Any tips on what I can do this to work?

I use my program as this

1. julia --project=.
2. using Distributed
3. addprocs(4)
4. using Intro

It then crashes

---

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [April 19, 2024, 5:52am UTC](https://discourse.julialang.org/t/unable-to-create-parallel-package/113207/2 "2024-04-19T05:52:55Z")

</div>

Note there is a missing parenthesis here before the comma:

> [@jafagervik](#):
>
> ```julia
> function mad() 
> pmap(_ -> println("$(myid())", 1:10)
> end
> 
> ```

The error stems from the fact that you put `@everywhere` inside the module so it runs during precompilation which does not make a lot sense. What you should do instead is to remove the `@everywhere` from `test.jl` and use it when you **load** the package such that it is correctly loaded on all workers:  
`julia --project=.`

```julia-repl
julia> using Distributed; addprocs(4);
julia> @everywhere using Intro
julia> mad()
      From worker 4:	4
      From worker 3:	3
      From worker 5:	5
      From worker 2:	2
      From worker 4:	4
      From worker 3:	3
      From worker 2:	2
      From worker 4:	4
      From worker 5:	5
      From worker 3:	3
10-element Vector{Nothing}:
 nothing
 nothing
 nothing
 nothing
 nothing
 nothing
 nothing
 nothing
 nothing
 nothing

```
