# Obtain base path of sources to resolve error messages

**URL:** https://discourse.julialang.org/t/obtain-base-path-of-sources-to-resolve-error-messages/6823
**Category:** Internals & Design
**Tags:** question
**Created:** [November 1, 2017, 10:38am UTC](https://discourse.julialang.org/t/obtain-base-path-of-sources-to-resolve-error-messages/6823 "2017-11-01T10:38:38Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [November 1, 2017, 10:38am UTC](https://discourse.julialang.org/t/obtain-base-path-of-sources-to-resolve-error-messages/6823/1 "2017-11-01T10:38:38Z")

</div>

I am working on making error message locations “clickable” in Emacs. How can I obtain the directory (in Julia) that `./loading.jl` and the other files are resolved in the example below:

```julia
julia> include("/tmp/Foo.jl")
WARNING: replacing module Foo
ERROR: LoadError: UndefVarError: T not defined
Stacktrace:
 [1] include_from_node1(::String) at ./loading.jl:576
 [2] include(::String) at ./sysimg.jl:14
while loading /tmp/Foo.jl, in expression starting on line 9

```

It should work for binary and source compiled distributions. `Base.JULIA_HOME` takes me to the executable, in can join it with `../share/julia/base/` for binary distributions or `base/` for compiled source, but I imagine that there is something portable, I just could not find it.

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [November 1, 2017, 10:43am UTC](https://discourse.julialang.org/t/obtain-base-path-of-sources-to-resolve-error-messages/6823/2 "2017-11-01T10:43:12Z")

</div>

Have a look at `fullpath` and related functions [here](https://github.com/JunoLab/Atom.jl/blob/master/src/utils.jl) for an implementation that seems to work quite well so far.

Edit: Which does exactly what you propose, so it probably won’t help much 🙂 Should’ve read all of your post before answering.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [November 1, 2017, 10:50am UTC](https://discourse.julialang.org/t/obtain-base-path-of-sources-to-resolve-error-messages/6823/3 "2017-11-01T10:50:22Z")

</div>

Thanks anyway. Forgot to mention: I need something that I can run on a “bare” installation (no packages). The idea is that I call

```bash
julia -qe <magic-base-path>

```

from Emacs and just process the output. The magic can be quite long, no problem with that. What about

```julia
normpath(joinpath(JULIA_HOME, Base.DATAROOTDIR, "julia", "base"))

```

Seems to work.

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [November 1, 2017, 10:53am UTC](https://discourse.julialang.org/t/obtain-base-path-of-sources-to-resolve-error-messages/6823/4 "2017-11-01T10:53:58Z")

</div>

Sure, I didn’t mean to suggest you should depend on Atom for that 🙂

Your solution seems to work pretty well though from what I can tell.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [November 1, 2017, 12:36pm UTC](https://discourse.julialang.org/t/obtain-base-path-of-sources-to-resolve-error-messages/6823/5 "2017-11-01T12:36:27Z")

</div>

The next question is: how can I minimize runtime for this? Currently I run

```bash
julia --history-file=no --startup-file=no -qe \
print("OK" * normpath(joinpath(JULIA_HOME, Base.DATAROOTDIR, "julia", "base")))

```

where I examine the output for the prefix `OK` to check that things went well.

Is there anything else I can do besides disabling history and the startup file? It takes `0.2s` which I can live with, but less is always better.
