# VSCode LOAD\_PATH discussion

**URL:** <https://discourse.julialang.org/t/vscode-load-path-discussion/34085>\
**Category:** VS Code\
**Tags:** code-organization\
**Created:** [January 30, 2020, 6:20pm UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085 "2020-01-30T18:20:26Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Pbellive](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pbellive/32/3604_2.png) [@Pbellive](https://discourse.julialang.org/u/Pbellive)\
**Post date:** [February 3, 2020, 10:15pm UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085/21 "2020-02-03T22:15:36Z")

</div>

In addition to what @GunnarFarneback just posted, I’d like to add to @davidanthoff’s last post, which explains that not only do you not need a git repo to make a julia package, you don’t need a julia package to add a folder to an environment. I think this might be able to more or less keep your current workflow without using LOAD\_PATH, creating any packages or doing anything with git. Recall David’s post:

> [@ufechner7](#):
>
> > But why should have create a package if I don’t need one?
> 
> One can easily dev local folders that are not full blown packages in their own git repo. I think the minimal requirement that something can be deved is just that there is a folder `src` , and then a file `ModuleName.jl` in that `src` folder. No need for anything else, as far as I can tell (certainly not a git repo).

One can make a julia module, just sitting in a folder on your machine, not part of any project, available as part of your environment without using LOAD\_PATH. You can do all of this through the package manager repl mode, without having to create any packages. Once these modules are part of the vs code extension’s active environment, they will be picked up by the extension and used in linting etc.

Perhaps this could be better documented. Here’s an example. Let’s say I create two modules, `FooMod` and `BarMod`. These modules each consist of single files, FooMod.jl and BarMod.jl, respectively. The directories storing these modules looks like so:

```julia
FooMod
└── src
    └── FooMod.jl

```

```julia
BarMod
└── src
    └── BarMod.jl

```

And that’s it, no Project.toml, no git stuff.

BarMod.jl could contain, for example

```julia
module BarMod

export bar

using FooMod

bar() = println(foo()*"baaaaaaaaaaar")

end

```

Now, assuming I have these directory structures and files defined, in julia I can do the following from the Pkg repl mode to add these modules to my current environment

```julia
pkg> dev /path-to/FooMod

```

and the same for BarMod. This adds these two modules to my current environment. Then I can then do `using FooMod, BarMod` from any directory on my system without touching LOAD\_PATH. vs code will also pick up these modules, assuming your active julia environment for the vs code extension has these modules in there.

---

<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 4, 2020, 6:31am UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085/22 "2020-02-04T06:31:46Z")

</div>

> [@ufechner7](#):
>
> But why should have create a package if I don’t need one?

You need one, you just don’t realize it.

> [@ufechner7](#):
>
> A lot of unnecessary overhead.

This is a misconception. Julia packages are very lightweight (comparable to branches in `git`). They are part of the normal workflow.

> [@ufechner7](#):
>
> I prefer to have one git repository for one program, which might include 5 modules to split up the code in units that can be tested separately.

You can of course have multiple modules in a git repository. For all Julia cares, you can have your whole `~` in a git repository. This is an orthogonal question.

That said, the current tooling makes it slightly more convenient to have a repo for each package. But nothing prevents you from cloning a repo, `pkg> dev`ig a “main” project, which has relative paths to other modules in the manifest.

The bottom line is that there is a solution to your workflow problem, so refusing to use it and sticking to the obsolete `LOAD_PATH` puts you in a position where it may be difficult to get community support.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [February 4, 2020, 7:50am UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085/23 "2020-02-04T07:50:59Z")

</div>

> [@Tamas\_Papp](#):
>
> obsolete `LOAD_PATH`

While I appreciate all the suggestions made in this thread, to say that LOAD\_PATH is obsolete is a bold statement.  
Where can I find this information in the Julia documentation?  
Where can I find the information: If you want to structure your code using modules, please create a Package first?  
I do not think that this statement is backed by facts, correct me if I am wrong.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [February 4, 2020, 8:14am UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085/24 "2020-02-04T08:14:22Z")

</div>

> [@ufechner7](#):
>
> Where can I find this information in the Julia documentation?

I don’t see why you would trust documentation more than the people that tend to write the documentation / package manager directly telling you something. If the docs suggest that modifying `LOAD_PATH` is a good workflow for everyday use, then they should be amended.

> [@ufechner7](#):
>
> And as far as I know every Julia package needs a separate git repository.

Maybe this is the core of the problem. This is not true. A julia package needs:

- A file called `Project.toml` with a UUID and name entry.
- A file `src/Package.jl` file that defines `module Package ... end`.

`generate` in Pkg creates this for you if you do `generate Package`.

Anyway, It is totally fine to use scripts (not packages) but then you tend to just `include` by path which doesn’t require modifying `LOAD_PATH`.

---

<div class="post-metadata">

**Author:** ![YongHee-Kim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yonghee-kim/32/5965_2.png) [@YongHee-Kim](https://discourse.julialang.org/u/YongHee-Kim)\
**Post date:** [February 4, 2020, 8:32am UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085/25 "2020-02-04T08:32:00Z")

</div>

**For the sake of argument** , I will assume vscode extension is competing with Juno to win over users, and you have to choose between developing debugger or support for LOAD\_PATH

I was comparing Juno and vscode a year ago, and used both of them at the same time for comparison. And eventually decided to use vscode even LOAD\_PATH doesn’t work on vscode at that time. Because I could work around LOAD\_PATH problem with `pkg>dev MyModule`

So, I think a lack of support for LOAD\_PATH would be fine. if enough users are going to adopt `pkg>dev MyModule` as their workflow.  
But on the other hand, If users want to use Debugger have no choice but use Juno.

So if the final goal of vscode is to win users over Juno, I think debugger is a more pressing matter because Juno has them and there is no workaround to use debugger in vscode.

---

<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 4, 2020, 8:49am UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085/26 "2020-02-04T08:49:28Z")

</div>

> [@ufechner7](#):
>
> Where can I find this information in the Julia documentation?

You can compare current and pre-Pkg3 docs. TL;DR: `LOAD_PATH` used to be part of the recommended workflow, and _for most purposes_ these uses have been superseded by the new Pkg workflow. `LOAD_PATH` is still there but it is no longer something users would modify routinely.

> [@ufechner7](#):
>
> Where can I find the information: If you want to structure your code using modules, please create a Package first?

In the discussion above, for example, with multiple people telling you this. A lot of the documentation is catching up about these things, and there are WIP issues, but the idea of using projects to organize your code has been around since [the first JULEP on the issue](https://github.com/JuliaLang/Juleps/blob/master/Pkg3.md#project-environments).

> [@ufechner7](#):
>
> I do not think that this statement is backed by facts

I think you are approaching this wrong. We are not talking about how to interpret a fully specified standard, but solving a problem in the context of the current code loading and Pkg features, some of which are WIP.

---

<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 4, 2020, 8:51am UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085/27 "2020-02-04T08:51:20Z")

</div>

> [@kristoffer.carlsson](#):
>
> If the docs suggest that modifying `LOAD_PATH` is a good workflow for everyday use, then they should be amended.

I think that applies [here (1/b)](https://docs.julialang.org/en/v1.5-dev/manual/workflow-tips/#Revise-based-workflows-1). Perhaps `pkg> activate` would be a better choice.

---

<div class="post-metadata">

**Author:** ![rapus95](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rapus95/32/3773_2.png) [@rapus95](https://discourse.julialang.org/u/rapus95)\
**Post date:** [February 4, 2020, 9:38am UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085/28 "2020-02-04T09:38:48Z")

</div>

> [@ufechner7](#):
>
> As background information, the reason why I am so frustrated is that this all used to work three years ago, but since 2.5 years it doesn’t work any more, and there seams to be no way forward to fix it.

I guess I see the problem.

Meanwhile:

1. Julia 1.0
2. new Pkg
3. reinvented workflow

So, while one can still consider it a vscode bug it is just not meant to be the common workflow. Thus, rather than complaining about missing support for pre-1.0 style (whose support is allowed to be dropped in 1.0 according to SemVer) you might need to go with the time and update your own workflow for the post Julia 1.0 world. Requesting stronger support in that direction is like requesting Tier 1 support for pre 1.0 Julia.

> [@ufechner7](#):
>
> Where can I find this information in the Julia documentation?

As kristoffer said, `LOAD_PATH` in the workflow & package sections can be considered outdated and thus an issue/PR would be a good idea.

But as that all won’t help you (and tbh I still am wrapping my own head around the new best practices/workflow) there are some resources & discussions which might help you wrapping yours around:

1. [Workflow Tips · The Julia Language](https://docs.julialang.org/en/v1/manual/workflow-tips/)
2. [Julia workflow](https://discourse.julialang.org/t/julia-workflow/21993)  
and a few more which I can’t find right now. One of this community also wrote a blogpost last year IIRC.

Either way, Julia is (fortunately) still fast evolving, though, since 1.0 (sadly) only in a very restricted non-breaking manner. (Looking forward to 2.x).

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [February 4, 2020, 7:22pm UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085/29 "2020-02-04T19:22:14Z")

</div>

> [@kristoffer.carlsson](#):
>
> A file called `Project.toml` with a UUID and name entry.

Is that even needed? I was able to `dev folderFoo`, where the only thing in `folderFoo` is `src/folderFoo.jl`, but no `Project.toml`.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [February 4, 2020, 8:38pm UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085/30 "2020-02-04T20:38:05Z")

</div>

Okay, that’s a remnant for backwards compat with REQUIRE files. Gone on 1.4 though.

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [February 4, 2020, 9:15pm UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085/31 "2020-02-04T21:15:03Z")

</div>

Ah, good to know.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [February 5, 2020, 7:28am UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085/32 "2020-02-05T07:28:41Z")

</div>

So I tried to dev my project. This is how far I got:

cd ~/myproject  
julia --project

```julia
(myproject) pkg> dev .
ERROR: expected a `name` entry in project file at /home/ufechner/myproject/Project.toml

(Myproject) pkg> dev .
ERROR: expected a `uuid` entry in project file at /home/ufechner/myproject/Project.toml

(Myproject) pkg> dev .
ERROR: expected the file `src/Myproject.jl` to exist for package Myproject at .

(Myproject) pkg> dev .
ERROR: Cannot `develop` package with the same name or uuid as the project

(Myproject) pkg> 

```

And the Project.toml file:

```julia
name = "Myproject"
uuid = "e522e412-47e6-11ea-24f1-c3520112404c"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
...

```

I fixed the first three errors, but I do not know how to fix the last one.

Any idea?

---

<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 5, 2020, 9:07am UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085/33 "2020-02-05T09:07:08Z")

</div>

If it is a project, I would just `pkg> activate` it. Which you are already doing the way you invoke Julia.

Why would you want to `dev` a project within itself? I don’t think that makes sense. I think that reading the first few chapters of the [Pkg docs](https://julialang.github.io/Pkg.jl/dev/) would be useful at this point.

TL;DR:

1. one would usually work with a project by activating it (which is what you are doing above).

2. if it is a package that you are developing, you may want to `dev` it in the default project.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [February 5, 2020, 5:36pm UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085/34 "2020-02-05T17:36:32Z")

</div>

The point is, I was told that I shall NOT use LOAD\_PATH and that vscode finds functions that are defined in modules of a dev’ed package.

But this does not seam to work.

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [February 5, 2020, 6:20pm UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085/35 "2020-02-05T18:20:23Z")

</div>

@ufechner7, I think you just need to read up on how to use env and how the `dev` thing works. What you are attempting in your example (to activate the local folder as the active project, _and_ then `dev` the local folder) is not how the env support in Julia works.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [February 5, 2020, 6:48pm UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085/36 "2020-02-05T18:48:40Z")

</div>

In other words, there is no viable alternative to the use of LOAD\_PATH.

---

<div class="post-metadata">

**Author:** ![IljaK91](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iljak91/32/44301_2.png) [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Post date:** [February 6, 2020, 6:02pm UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085/37 "2020-02-06T18:02:37Z")

</div>

You just have to be in your standard environment, then you can dev your project and type “using MyProject”. Any changes to your project will be automatically available via Revise. Then the linter should also work. You only use the environment of your project when you want to change which packages are loaded by your project. That’s it, I tried that as well (I didn’t check the linter part, but can do so at the next opportunity).

---

<div class="post-metadata">

**Author:** ![IljaK91](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iljak91/32/44301_2.png) [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Post date:** [February 7, 2020, 9:55am UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085/38 "2020-02-07T09:55:37Z")

</div>

I tried now turning on the Linter and I still get the “Missing Reference” annotation for the dev’d package even after “using MyPackage”. So it does not seem to be a solution to the problem after all.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [February 8, 2020, 4:03am UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085/39 "2020-02-08T04:03:34Z")

</div>

I can confirm than using “dev .” does not help to make the linter work.

But another work-around was found and is described in the following comment: [Linter doesn't check `LOAD_PATH` for packages · Issue #307 · julia-vscode/julia-vscode · GitHub](https://github.com/julia-vscode/julia-vscode/issues/307#issuecomment-583698992) 🙂

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [February 8, 2020, 10:45pm UTC](https://discourse.julialang.org/t/vscode-load-path-discussion/34085/40 "2020-02-08T22:45:35Z")

</div>

Thanks to this new workaround I was able to get rid of 1200 false positives (warnings). 5-6 warnings remained, indicating real problems. 🙂

[Previous page](https://discourse.julialang.org/t/vscode-load-path-discussion/34085.md?page=1)

[Next page](https://discourse.julialang.org/t/vscode-load-path-discussion/34085.md?page=3)
