# @everywhere include() does not work with relative file paths

**URL:** https://discourse.julialang.org/t/everywhere-include-does-not-work-with-relative-file-paths/9598
**Category:** New to Julia
**Tags:** question
**Created:** [March 8, 2018, 4:05pm UTC](https://discourse.julialang.org/t/everywhere-include-does-not-work-with-relative-file-paths/9598 "2018-03-08T16:05:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Pyrena](https://avatars.discourse-cdn.com/v4/letter/p/4bbf92/32.png) [@Pyrena](https://discourse.julialang.org/u/Pyrena)
#### Post date: [March 8, 2018, 4:05pm UTC](https://discourse.julialang.org/t/everywhere-include-does-not-work-with-relative-file-paths/9598/1 "2018-03-08T16:05:51Z")

</div>

Suppose I have a file located at `dir/ModuleA.jl`:

```julia
module ModuleA
    export f

    function f()
        return("foo")
    end
end

```

and another file located at `dir/main.jl`:

```julia
addprocs(4)
@everywhere include("ModuleA.jl")

```

Running main.jl from inside `dir` with `julia main.jl` works fine, but fails from anywhere else because worker 2 tries to locate `ModuleA.jl` inside the current working directory.  
As a fix I tried

```julia
@everywhere include(joinpath(@ __DIR__ , "ModuleA.jl"))

```

but `@ __DIR__ ` returns `nothing` on the workers.

Can someone enlighten me what’s happening here?  
The problem I want to solve is making an existing module available on all workers while still being able to call the script from any working directory.

---

<div class="post-metadata">

### Author: ![mebrunet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mebrunet/32/2519_2.png) [@mebrunet](https://discourse.julialang.org/u/mebrunet)
#### Post date: [June 4, 2018, 9:49pm UTC](https://discourse.julialang.org/t/everywhere-include-does-not-work-with-relative-file-paths/9598/2 "2018-06-04T21:49:52Z")

</div>

I agree this behavior feels broken. The `include` function treats relative paths differently if called on the main process or on a worker.

on main: “relative” is relative to the file location  
on workers: “relative” is relative to the working directory

---

<div class="post-metadata">

### Author: ![mebrunet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mebrunet/32/2519_2.png) [@mebrunet](https://discourse.julialang.org/u/mebrunet)
#### Post date: [June 4, 2018, 10:10pm UTC](https://discourse.julialang.org/t/everywhere-include-does-not-work-with-relative-file-paths/9598/3 "2018-06-04T22:10:18Z")

</div>

My current work around is:

```julia
function include_everywhere(filepath)
    fullpath = joinpath(@ __DIR__ , filepath)
    @sync for p in procs()
        @async remotecall_wait(include, p, fullpath)
    end
end

include_everywhere("MyMod.jl")
using MyMod

```
