Julia Source Code Directory

Hi, I am new to Julia, previously work primarily on VBA, a little C++, Matlab and Python.

This is literally my second Julia Script after Hello World.

I was wondering (and i have searched on google and this forum already) , how do I get the directory of my current script?

I have VSCode installed on Windows 10
I have tried pwd() and base.source_dir() , however both are listing my user’s home directory instead of my script directory

My script is stored under: C:\Users\nelso\Documents\Julia\myscript.jl
When using pdw() or base.source_dir(), Julia returns “C:\Users\nelso”

What do i have to do for Julia to give me “C:\Users\nelso\Documents\Julia”



Expand to a string with the absolute path to the directory of the file containing the macrocall. Return the current working directory if run from a REPL or if evaluated by julia -e <expr> .

Hi Findmyway,

I have followed your lead and use println(@DIR) , but I got:

instead of
“C:\users\nelso\Documents\Julia” which I want (where the myscript.jl is stored)

any more clues?

THanks again

You’re probably looking for @__FILE__. Check the REPL help mode (enter ? and then whatever you want to look up) or the docs for more information.

Thanks Team,

Looking at another thread,

using ctrl-enter will yield what i get, and using alt-enter is a better way to execute code, and get what i actually want.

take care