# Get path to julia install?

**URL:** <https://discourse.julialang.org/t/get-path-to-julia-install/65315>\
**Category:** General Usage\
**Created:** [July 26, 2021, 3:44pm UTC](https://discourse.julialang.org/t/get-path-to-julia-install/65315 "2021-07-26T15:44:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnomotani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnomotani/32/26753_2.png) [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Post date:** [July 26, 2021, 3:44pm UTC](https://discourse.julialang.org/t/get-path-to-julia-install/65315/1 "2021-07-26T15:44:22Z")

</div>

I’ve been doing some memory profiling using `--track-allocation=all`. This puts output files in the same location as the source files, including in the base julia install, e.g. `base/multidimensional.jl.27819.mem`. Now I know where these files are on my own machine, but I’d like to write some generic scripts to profile my code, and then read the profiles. `Coverage.jl` handles most of this nicely, but needs to be passed the directories to search for `*.mem` files. So my question is: how do I (within a Julia script) get the path to the julia installation directory (containing `base/` and `stdlib/`)? For bonus points, is there a way to get the equivalent of `~/.julia` if it’s not in the default location?

---

<div class="post-metadata">

**Author:** ![johnomotani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnomotani/32/26753_2.png) [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Post date:** [July 26, 2021, 4:02pm UTC](https://discourse.julialang.org/t/get-path-to-julia-install/65315/2 "2021-07-26T16:02:33Z")

</div>

One way that might work is to follow this StackOverflow answer: [How to find the path of a package in Julia? - Stack Overflow](https://stackoverflow.com/a/63883681/13577592). The function suggested there

```julia
julia> module_file(modu) = String(first(methods(getfield(modu, :eval))).file)

```

doesn’t help if I try to find the directory for `Base`

```julia
julia> module_file(Base)
"Base.jl"

```

but for something in the standard library, e.g. `REPL`, it does give a path which I could then use to figure out the install directory I wanted. Surely there must be an easier way though?

---

<div class="post-metadata">

**Author:** ![greg\_plowman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/greg_plowman/32/8100_2.png) [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Post date:** [July 26, 2021, 10:21pm UTC](https://discourse.julialang.org/t/get-path-to-julia-install/65315/3 "2021-07-26T22:21:43Z")

</div>

> [@johnomotani](#):
>
> how do I (within a Julia script) get the path to the julia installation directory (containing `base/` and `stdlib/` )?

Maybe you can find the directory relative to `Sys.BINDIR`, which is the full path to the directory containing the julia executable:

`joinpath(Sys.BINDIR, "..", "share", "julia")`

> [@johnomotani](#):
>
> is there a way to get the equivalent of `~/.julia` if it’s not in the default location?

Perhaps you can extract from `DEPOT_PATH`. See [Constants · The Julia Language](https://docs.julialang.org/en/v1.6/base/constants/#Base.DEPOT_PATH)

`first(DEPOT_PATH)`

---

<div class="post-metadata">

**Author:** ![johnomotani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnomotani/32/26753_2.png) [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Post date:** [July 27, 2021, 10:20am UTC](https://discourse.julialang.org/t/get-path-to-julia-install/65315/4 "2021-07-27T10:20:01Z")

</div>

Thanks @greg_plowman! You’ve answered the question I asked. It turns out for my actual use case, `DEPOT_PATH` is even better - it looks like that’s the set of almost all directories where source files might be (it looks to me like it doesn’t include packages added with `Pkg.develop()` though), so I can just pass that (plus the directory with the source for my package) to `Coverage.analyze_malloc()` instead of having to handle base/stdlib and `~/.julia` separately. Awesome!

Edit: I ended up needing `[x for x in DEPOT_PATH if isdir(x)]` because `.../julia-1.6.1/usr/local/share/julia` didn’t actually exist.

---

<div class="post-metadata">

**Author:** ![Fliks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fliks/32/2494_2.png) [@Fliks](https://discourse.julialang.org/u/Fliks)\
**Post date:** [July 27, 2021, 1:47pm UTC](https://discourse.julialang.org/t/get-path-to-julia-install/65315/5 "2021-07-27T13:47:56Z")

</div>

Packages that are `Pkg.develop` ed are either in `DEPOT_PATH/dev` so this should be dealt with you solution already or they are in where `JULIA_PKG_DEVDIR` points to. See [3. Managing Packages · Pkg.jl](http://pkgdocs.julialang.org/v1/managing-packages/#developing).
