# How do I push a value to all processes?

**URL:** <https://discourse.julialang.org/t/how-do-i-push-a-value-to-all-processes/25552>\
**Category:** General Usage\
**Tags:** distributed\
**Created:** [June 22, 2019, 8:10pm UTC](https://discourse.julialang.org/t/how-do-i-push-a-value-to-all-processes/25552 "2019-06-22T20:10:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pixel27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel27/32/8902_2.png) [@pixel27](https://discourse.julialang.org/u/pixel27)\
**Post date:** [June 22, 2019, 8:10pm UTC](https://discourse.julialang.org/t/how-do-i-push-a-value-to-all-processes/25552/1 "2019-06-22T20:10:29Z")

</div>

First what I’m trying to do:

```julia
using Distributed
addprocs(1)

target = string(@ __DIR__ , "/dir2/d2.jl")
@everywhere include(target)

```

With a directory structure like:

- /dir1
  - m1.jl
  - /dir 2
    - d2.jl

The above code is in m1.jl. This is giving me an error `UndefVarError: target not defined` on worker 2. For development I’m running this under Atom, which means the root directory from which julia is started is the root of the project. However when running “normally” I would expect my current directory to be “dir1”…probably.

The above could (if it worked) also handle the situation if the current directory is NOT dir1, like if I executed: `julia ~/project/dir1/m1.jl` from the console. If I just did `@everywhere include("dir2/d2.jl")` I’m restricted to only being able to run if my current directory is `dir1`.

---

<div class="post-metadata">

**Author:** ![pmarg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pmarg/32/936_2.png) [@pmarg](https://discourse.julialang.org/u/pmarg)\
**Post date:** [June 22, 2019, 8:24pm UTC](https://discourse.julialang.org/t/how-do-i-push-a-value-to-all-processes/25552/2 "2019-06-22T20:24:47Z")

</div>

Try:

```julia
@everywhere target = string(@ __DIR__ , "/dir2/d2.jl")
@everywhere include(target)

```

---

<div class="post-metadata">

**Author:** ![pixel27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel27/32/8902_2.png) [@pixel27](https://discourse.julialang.org/u/pixel27)\
**Post date:** [June 22, 2019, 8:28pm UTC](https://discourse.julialang.org/t/how-do-i-push-a-value-to-all-processes/25552/3 "2019-06-22T20:28:48Z")

</div>

Well that’s embarrassing, that worked. I didn’t try it because I just assumed `@ __DIR__ ` would expand on the distributed process…

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![bernhard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bernhard/32/2619_2.png) [@bernhard](https://discourse.julialang.org/u/bernhard)\
**Post date:** [June 22, 2019, 8:46pm UTC](https://discourse.julialang.org/t/how-do-i-push-a-value-to-all-processes/25552/4 "2019-06-22T20:46:45Z")

</div>

I think `@ __DIR__ ` is not the issue in your code.  
The problem is that target is only defined in the main process.

---

<div class="post-metadata">

**Author:** ![greg\_plowman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/greg_plowman/32/8100_2.png) [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Post date:** [June 23, 2019, 3:24am UTC](https://discourse.julialang.org/t/how-do-i-push-a-value-to-all-processes/25552/5 "2019-06-23T03:24:03Z")

</div>

Or interpolate the value of `target`:

```julia
target = string(@ __DIR__ , "/dir2/d2.jl")
@everywhere include($target)

```
