# Julia relative imports, issue #4600, exactly how "not that difficult" is it?

**URL:** <https://discourse.julialang.org/t/julia-relative-imports-issue-4600-exactly-how-not-that-difficult-is-it/34503>\
**Category:** Internals & Design\
**Tags:** question\
**Created:** [February 12, 2020, 6:24am UTC](https://discourse.julialang.org/t/julia-relative-imports-issue-4600-exactly-how-not-that-difficult-is-it/34503 "2020-02-12T06:24:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DevJac](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@DevJac](https://discourse.julialang.org/u/DevJac)\
**Post date:** [February 12, 2020, 6:24am UTC](https://discourse.julialang.org/t/julia-relative-imports-issue-4600-exactly-how-not-that-difficult-is-it/34503/1 "2020-02-12T06:24:20Z")

</div>

I’ve reached the point in my Julia journey where I’m seeing the limitations of `include` for assembling lots of modules into a project. It seems [https://github.com/JuliaLang/julia/issues/4600](https://github.com/JuliaLang/julia/issues/4600) is the answer, but progress seems slow. Fortunately, @StefanKarpinski claims that it “shouldn’t be that difficult” and tags “help wanted”.

I want to help. I’m willing to put a few dozen hours into this feature during the next few weeks.

But how “not that difficult” is this issue? I’ve never worked on a project as large as Julia, and I can read some C, but have never written much of it? Can I help?

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [February 12, 2020, 6:45am UTC](https://discourse.julialang.org/t/julia-relative-imports-issue-4600-exactly-how-not-that-difficult-is-it/34503/2 "2020-02-12T06:45:01Z")

</div>

I would recommend that you discuss in the original issue (I think it is OK to ask for help there, too).

The first thing I would check is if the [proposed solution](https://github.com/JuliaLang/julia/issues/4600#issuecomment-327573232) is still the recommended approach — it was more than 2 years ago.

I think most of this code is in `base/loading.jl`.

(I have moved your topic from Jobs, since I am assuming that you are willing to do this unpaid 😉)

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [February 12, 2020, 4:16pm UTC](https://discourse.julialang.org/t/julia-relative-imports-issue-4600-exactly-how-not-that-difficult-is-it/34503/3 "2020-02-12T16:16:40Z")

</div>

Last I looked at this, you need to modify the logic in

> <https://github.com/JuliaLang/julia/blob/master/src/module.c>

to implement the behavior described in [#4600](https://github.com/JuliaLang/julia/issues/4600).

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [February 12, 2020, 4:17pm UTC](https://discourse.julialang.org/t/julia-relative-imports-issue-4600-exactly-how-not-that-difficult-is-it/34503/4 "2020-02-12T16:17:43Z")

</div>

Note that a technique for importing submodules from relative paths is currently

```julia
include(“path/to/MyModule.jl”)
import .MyModule # note .

```

Syntactic sugar for this might be nice but is not essential.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [February 12, 2020, 5:14pm UTC](https://discourse.julialang.org/t/julia-relative-imports-issue-4600-exactly-how-not-that-difficult-is-it/34503/5 "2020-02-12T17:14:49Z")

</div>

I think the most important contribution of implementing #4600 for this would be standardizing the file paths for files that define modules, since you can’t use the relative import without `include` call unless the paths match the module names. Aside from that, it doesn’t really make much of a practical difference—it’s literally just about saving you from typing that `include` line. I guess there’s cases where you might avoid having to think about which code that uses a relative submodule should include it (the first user), which is nice too.

---

<div class="post-metadata">

**Author:** ![DevJac](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@DevJac](https://discourse.julialang.org/u/DevJac)\
**Post date:** [February 14, 2020, 6:21pm UTC](https://discourse.julialang.org/t/julia-relative-imports-issue-4600-exactly-how-not-that-difficult-is-it/34503/6 "2020-02-14T18:21:18Z")

</div>

Thanks for the replies.

I ended up solving the problem that was motivating me to work on this issue by modifying the `LOAD_PATH`. Now that I know `include`s are not the only way to organize a project, things aren’t nearly as bad as they seemed.

I added my project’s `src` directory to the `LOAD_PATH`, and then renamed some source files to match the name of their module. I think what I have now is called a “[package directory](https://docs.julialang.org/en/v1/manual/code-loading/#Package-directories-1)”?

You talked about “standardizing the file paths for files that define modules”. Isn’t this what package directories do already? As far as I understand, #4600 would give me nothing that package directories do not already give me, except maybe relative imports could work without having to modify the `LOAD_PATH`?
