How to include a module from a specific path directory in REPL of VS Code?

I have a module called (SynchronousMachines) in this path directory (C:\Work\Julia\Simulation\SynchronousMachine), as seen below:

I need to include this module from the RELP (not main code) in VS code. For this I am writing the below code but I am having an error:

julia> include(".\\..\\SynchronousMachine\\SynchronousMachines.jl")
ERROR: SystemError: opening file "C:\\Users\\SynchronousMachine\\SynchronousMachines.jl": No such file or directory
Stacktrace:
  [1] systemerror(p::String, errno::Int32; extrainfo::Nothing)
    @ Base .\error.jl:168
  [2] #systemerror#62
    @ .\error.jl:167 [inlined]
  [3] systemerror
    @ .\error.jl:167 [inlined]
  [4] open(fname::String; lock::Bool, read::Nothing, write::Nothing, create::Nothing, truncate::Nothing, append::Nothing)
    @ Base .\iostream.jl:293
  [5] open
    @ .\iostream.jl:282 [inlined]
  [6] open(f::Base.var"#326#327"{String}, args::String; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base .\io.jl:328
  [7] open
    @ .\io.jl:328 [inlined]
  [8] read
    @ .\io.jl:434 [inlined]
  [9] _include(mapexpr::Function, mod::Module, _path::String)
    @ Base .\loading.jl:1144
 [10] include(fname::String)
    @ Base.MainInclude .\client.jl:444
 [11] top-level scope
    @ REPL[4]:1

julia> include("./../SynchronousMachine/SynchronousMachines.jl")
ERROR: SystemError: opening file "C:\\Users\\SynchronousMachine\\SynchronousMachines.jl": No such file or directory
Stacktrace:
  [1] systemerror(p::String, errno::Int32; extrainfo::Nothing)
    @ Base .\error.jl:168
  [2] #systemerror#62
    @ .\error.jl:167 [inlined]
  [3] systemerror
    @ .\error.jl:167 [inlined]
  [4] open(fname::String; lock::Bool, read::Nothing, write::Nothing, create::Nothing, truncate::Nothing, append::Nothing)
    @ Base .\iostream.jl:293
  [5] open
    @ .\iostream.jl:282 [inlined]
  [6] open(f::Base.var"#326#327"{String}, args::String; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base .\io.jl:328
  [7] open
    @ .\io.jl:328 [inlined]
  [8] read
    @ .\io.jl:434 [inlined]
  [9] _include(mapexpr::Function, mod::Module, _path::String)
    @ Base .\loading.jl:1144
 [10] include(fname::String)
    @ Base.MainInclude .\client.jl:444
 [11] top-level scope
    @ REPL[6]:1

Any advice?
Thanks

Why do you use a relative path?
Just use the full path:

include("C:\\Work\\Julia\\Simulation\\SynchronousMachine\\SynchronousMachines.jl")

If you want to use a relative path, you need to check

pwd()

to see where you are. Or you set your current path explicitly with:

cd("C:\\Work\\Julia\\Simulation\\SOME_PATH...")
1 Like

I am using a relative path, because I am regularly sharing the folder of julia codes with my colleagues. So, avoiding the trouble of inserting different full paths on the REPLs of different computers.

I see.
I am not sure if you can expect that the current working directory after starting the REPL to be always the same for everybody.
I have e.g. a starting path in my startup.jl which is not the one a plain REPL starts with on windows.

1 Like

Have a look at

this may be the solution for your use case.

Thank you very much!