How to make vscode aware of user modules

May I ask some follow-on questions? I’m having similar problems moving to VSCode from Juno.

  1. Do you keep your package source code in ~/.julia/dev? (Correct me if I’m wrong, but this seems to be the default location for PkgTemplates, and is required for introspection by the VSCode language server.)
  2. If not, how do you synchronize your package source code with .julia/dev? (I’ve read most of the Pkg documentation, but must have missed this part.)
  3. More generally, would you mind sketching out your package development workflow?

Let me know if I ought to be starting a different topic. Thank you very much.


I don’t.

I keep code at an arbitrary location (~/code/julia/Foo for Foo.jl), and activate it if I am working on it.

This also isn’t true. You just need to point VSCode to the correct environment via the env selector in the lower left (modulo some bugs in our env handling that should be fixed in the next minor release).

1 Like

I’m unable to get autocompletion to work in VSCode for user-defined modules except for those present in .julia/dev as packages. Is this user-error, or one of the bugs to which you alluded?

1 Like

Can someone post a step-by-step guide to creating a project where autocomplete works across different files in that project?


Well, for me it works if I have one file in which I define a module, lets call it Utils.jl

module Utils
export my_test

function my_test()


and a main program that includes this module in the same directory:

using .Utils


If I now right click on my_test() I can select “Go to Definition” and it works.

The main program and the module(s) that you include do not have to be in the same directory,
but if they are not you have to adapt the relative path in the include statement.

Typing: my<TAB> should result in auto completion to my_test.

Does that work for you?


This works for me, thank you!

In contrast,

push!(LOAD_PATH, @__DIR__)
using Utils


, which is what I was using before, runs but does not autocomplete.

That is a known issue which might or might not be fixed at some point in time:

1 Like

Yeah, honestly, I’d recommend setting up a local environment instead of any LOAD_PATH shenanigans.

But that does not solve this issue. It is not even a work around.

Why not? If you’re using LOAD_PATH, it’s because you want to load a package somewhere. Instead just put that relationship into a Manifest and you’re good to go, no?

Could you say more about this workflow or post a link that explains it? I have a Project.toml and Manifest.toml that contain external libraries, which were auto-generated via Pkg.add, how do I add my own files to it?

If you’re using LOAD_PATH , it’s because you want to load a package somewhere.

I was using LOAD_PATH in the past not to load a package, but a module, usually in a file in the same directory.

A local environment does only help if you are a package developer. But many people just write projects, not packages. In that case my work around helps.

1 Like

Sure, but you weren’t doing anything with LOAD_PATH :slight_smile: That’s a perfectly fine solution for referencing local files.

Take a look at the Pkg docs. What I did to generate the above example was basically

$ mkdir VSCode-Test
$ cd VSCode-Test
$ mkdir Foo
$ echo 'name = "Foo"\nuuid = "a33f4f40-c364-4a1b-9be3-145a5eb10e1c"' > ./Foo/Project.toml
$ mkdir Foo/src
$ echo 'module Foo\nf(x)=x\nend' > ./src/Foo.jl
$ code .
$ julia --project=.
(VSCode-Test) pkg>dev ./Foo

and then right click on the Project.toml in VSCode and select Activate This Environment.


I created a package, which I named Experiments and I dump all my scripts in src. I also set up a startup.jl file inside .doc/config/ with something like

cd("path/to/experiments/")  # set up path to package
import Pkg

This is an all-purpose environment. I don’t have to have a push command or similar. This seems okay for short scripts and quick debugging of loops. Once in a while I delete everything below the # This file is machine-generated - editing it directly is not advised header in the Manifest.toml file and re-install packages as I need them.

Anything seriously wrong with this approach?

Sorry to dig this up again but I cannot get user defined modules to work with code completion. Reading through these post it seems if you have generated a package and added it to dev it should work.

[dustin@Odin-pc ~]$ julia
   _       _ _(_)_     |  Documentation:
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.6.1 (2021-04-23)
 _/ |\__'_|_|_|\__'_|  |  
|__/                   |

(@v1.6) pkg> status
      Status `~/.julia/environments/v1.6/Project.toml`
  [023a3684] GenieVue v0.1.0 `~/Git/Projects/genieplayground/GenieVue`
  [6696d0b5] RPGCombat v0.1.0 `~/Git/Projects/Katas/RPGCombat`

(@v1.6) pkg>

My Project.toml file looks like

name = "RPGCombat"
uuid = "6696d0b5-b9c1-4907-9ab0-32591776c20d"
authors = "Dustin"
version = "0.1.0"

Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

My env: is RPGcombat in VScode
I am setting something up incorrectly?