Some of the answers above are outdated / partial / didn't work for me so I thought I'd
give my two cents here as I had this exact need recently (using Julia 1.5.3).
First of all and unfortunately, Pkg.dir()
is deprecated and gets a warning when used.
To find the path where a module/package code resides you can use the Base.pathof(::Module)
function, for example:
julia> pathof(HTTP)
"C:\\Users\\User\\.julia\\packages\\HTTP\\IAI92\\src\\HTTP.jl"
To edit a module's code you can use the REPL, for example:
julia> edit(HTTP)
will open your editor at the HTTP module's souce code.
Alternatively, when using VSCode you can right click on a function call and use the Go to Definition (F12) context menu option and open to the source code in your editor (Atom has an equivalent Go to Declaration option but it did not work for me).
Note that you can resort to the quick-and-dirty method and just edit the code where you find it or you use a much cleaner way offered by the Julia Pkg module:
pkg> develop --local Example
This will create a git clone of the Example package under your current project root so you can work on a separate local copy of the package code in a development environment.
To stop working with the dev module use:
pkg> free Example
For more info refer to the Julia Pkg module documentation
Please keep in mind that (as already stated in the answers above) Julia pre-compiles modules on startup only, so unless you are using Revise.jl as pointed-out by Liso above, every change to a module's code requires restarting Julia in order to recompile the changed module.
this can be done by typing
julia> exit()
and running the using <Module Name>
statement again.
Edit: this question is closely related to:
How to find the path of a package in Julia
Edit: VSCode's Julia extension has an option for loading Revise.jl when starting the Julia REPL, the default for this option is true.