# How can I find line number of source code for ERROR?

**URL:** https://discourse.julialang.org/t/how-can-i-find-line-number-of-source-code-for-error/132787
**Category:** New to Julia
**Tags:** question
**Created:** [September 30, 2025, 1:54pm UTC](https://discourse.julialang.org/t/how-can-i-find-line-number-of-source-code-for-error/132787 "2025-09-30T13:54:36Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![psalm1750](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/psalm1750/32/210992_2.png) [@psalm1750](https://discourse.julialang.org/u/psalm1750)
#### Post date: [September 30, 2025, 1:54pm UTC](https://discourse.julialang.org/t/how-can-i-find-line-number-of-source-code-for-error/132787/1 "2025-09-30T13:54:36Z")

</div>

I am writing Julia code for some small project.  
But it seems that Julia script engine (/usr/bin/julia) does not display the line number for error detection.  
Althought it shows a line number, it is not the place where the error was detected,  
but the place of function which contains error.

Thanks in advance

---

<div class="post-metadata">

### Author: ![ForceBru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/forcebru/32/21389_2.png) [@ForceBru](https://discourse.julialang.org/u/ForceBru)
#### Post date: [September 30, 2025, 2:01pm UTC](https://discourse.julialang.org/t/how-can-i-find-line-number-of-source-code-for-error/132787/2 "2025-09-30T14:01:21Z")

</div>

Does it not go inside the function definition to show the exact line? Please post the relevant error message and explain what exactly is unclear about it.

---

<div class="post-metadata">

### Author: ![WalterMadelim](https://avatars.discourse-cdn.com/v4/letter/w/3e96dc/32.png) [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)
#### Post date: [September 30, 2025, 2:21pm UTC](https://discourse.julialang.org/t/how-can-i-find-line-number-of-source-code-for-error/132787/3 "2025-09-30T14:21:56Z")

</div>

When I was new to julia, I also seek for tools to help me dubug.  
But now I just use `println` and `error` to insert to suspicious places to help me locate the error.

---

<div class="post-metadata">

### Author: ![psalm1750](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/psalm1750/32/210992_2.png) [@psalm1750](https://discourse.julialang.org/u/psalm1750)
#### Post date: [September 30, 2025, 2:55pm UTC](https://discourse.julialang.org/t/how-can-i-find-line-number-of-source-code-for-error/132787/4 "2025-09-30T14:55:07Z")

</div>

Thank you for your replay , ForceBru.  
I will make some simple sample for explanation.

---

<div class="post-metadata">

### Author: ![psalm1750](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/psalm1750/32/210992_2.png) [@psalm1750](https://discourse.julialang.org/u/psalm1750)
#### Post date: [September 30, 2025, 3:00pm UTC](https://discourse.julialang.org/t/how-can-i-find-line-number-of-source-code-for-error/132787/5 "2025-09-30T15:00:04Z")

</div>

Oh, that’s too bad. It is same to me.

Almost all language can show some line number for error place.  
Or at least, has something like trace mode like “/bin/bash -x”.  
But I can not find them for Julia so far.  
I believe it is essential to locate error code.

---

<div class="post-metadata">

### Author: ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)
#### Post date: [September 30, 2025, 3:13pm UTC](https://discourse.julialang.org/t/how-can-i-find-line-number-of-source-code-for-error/132787/6 "2025-09-30T15:13:08Z")

</div>

Hi @psalm1750,  
Can you give an example of the code you’re running and for which the error is not precise enough? Please copy-paste the entire code, or at least the entire error message

---

<div class="post-metadata">

### Author: ![sgaure](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sgaure/32/14779_2.png) [@sgaure](https://discourse.julialang.org/u/sgaure)
#### Post date: [September 30, 2025, 5:46pm UTC](https://discourse.julialang.org/t/how-can-i-find-line-number-of-source-code-for-error/132787/7 "2025-09-30T17:46:46Z")

</div>

I usually get loads of line numbers:

```julia-auto
julia> using LinearAlgebra

julia> A = [0 1; 0 0]
2×2 Matrix{Int64}:
 0 1
 0 0

julia> inv(A)
ERROR: SingularException(1)
Stacktrace:
 [1] trsm!(side::Char, uplo::Char, transa::Char, diag::Char, alpha::Float64, A::Matrix{Float64}, B::Matrix{Float64})
   @ LinearAlgebra.BLAS ~/.julia/juliaup/julia-1.12.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.12/LinearAlgebra/src/blas.jl:2228
 [2] generic_trimatdiv!
   @ ~/.julia/juliaup/julia-1.12.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.12/LinearAlgebra/src/triangular.jl:1275 [inlined]
 [3] _ldiv!
   @ ~/.julia/juliaup/julia-1.12.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.12/LinearAlgebra/src/triangular.jl:1171 [inlined]
 [4] ldiv!
   @ ~/.julia/juliaup/julia-1.12.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.12/LinearAlgebra/src/triangular.jl:1178 [inlined]
 [5] inv(A::UpperTriangular{Int64, Matrix{Int64}})
   @ LinearAlgebra ~/.julia/juliaup/julia-1.12.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.12/LinearAlgebra/src/triangular.jl:1228
 [6] inv(A::Matrix{Int64})
   @ LinearAlgebra ~/.julia/juliaup/julia-1.12.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.12/LinearAlgebra/src/dense.jl:1083
 [7] top-level scope
   @ REPL[19]:1

```

Right after the file name, far out to the right, we can see e.g. `blas.jl:2228`, `triangular.jl:1275 [inlined]`, etc, etc,.  
The numbers on the left, `[1]`, `[2]` can be typed at the julia-prompt followed by ctrl-q to enter an editor on that line in the file. I.e. after the stack trace, to enter the `ldiv!` function:

```julia-auto
julia> 3<push ctrl-q>
...

```

Do you have an example where you don’t get them?

---

<div class="post-metadata">

### Author: ![WalterMadelim](https://avatars.discourse-cdn.com/v4/letter/w/3e96dc/32.png) [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)
#### Post date: [October 1, 2025, 12:42am UTC](https://discourse.julialang.org/t/how-can-i-find-line-number-of-source-code-for-error/132787/8 "2025-10-01T00:42:22Z")

</div>

> [@sgaure](#):
>
> The numbers on the left, `[1]`, `[2]` can be typed at the julia-prompt followed by ctrl-q to enter an editor on that line in the file

I don’t get this. It seems that `ctrl+q` is a VSCode action.  
But your instance here is a “nice” instance so that `ctrl+click` would jump to the file, which is convenient.  
There are other instances in which the `ctrl+click` won’t jump, so that I can only go to github to see the code, but in this case it is way more complicated.

```julia
julia> function b()
           println()
           local a = s.i, b = 4.
           println()
       end
b (generic function with 1 method)

julia> function a()
           println()
           b()
           println()
       end
a (generic function with 1 method)

julia> a()
ERROR: BoundsError: attempt to access Float64 at index [2]
Stacktrace:
 [1] indexed_iterate(I::Float64, i::Int64, state::Nothing)
   @ Base ./tuple.jl:168
 [2] b()
   @ Main ./REPL[1]:3
 [3] a()
   @ Main ./REPL[2]:3
 [4] top-level scope
   @ REPL[3]:1

```

In this case the [2], [3], [4] is not readable, the link in [1] has not hyperlink that I can jump to by clicking.

---

<div class="post-metadata">

### Author: ![psalm1750](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/psalm1750/32/210992_2.png) [@psalm1750](https://discourse.julialang.org/u/psalm1750)
#### Post date: [October 1, 2025, 4:59am UTC](https://discourse.julialang.org/t/how-can-i-find-line-number-of-source-code-for-error/132787/9 "2025-10-01T04:59:52Z")

</div>

Ddalle and all other julia menbers, thank you for all of your advice,  
And I found that “error line number” is provided in very dark color.  
I will check myself and will close my question.

Here, I attached tiny sample file for your reference.  
It has an error at line=2.  
But it seems to report at line=6.

Thank you for all.

[sample.jl](https://discourse.julialang.org/uploads/short-url/gqStlbilzEEclWSC1pcCx0fKNka.jl) (70 Bytes)

 ![error](https://global.discourse-cdn.com/julialang/original/3X/6/9/699ad57af92bea712d14a2561811f8381582f604.png)

---

<div class="post-metadata">

### Author: ![sgaure](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sgaure/32/14779_2.png) [@sgaure](https://discourse.julialang.org/u/sgaure)
#### Post date: [October 1, 2025, 7:03am UTC](https://discourse.julialang.org/t/how-can-i-find-line-number-of-source-code-for-error/132787/10 "2025-10-01T07:03:05Z")

</div>

> [@WalterMadelim](#):
>
> I don’t get this. It seems that `ctrl+q` is a VSCode action.

It’s in the REPL. I’ve never run VScode.

---

<div class="post-metadata">

### Author: ![WalterMadelim](https://avatars.discourse-cdn.com/v4/letter/w/3e96dc/32.png) [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)
#### Post date: [October 1, 2025, 8:37am UTC](https://discourse.julialang.org/t/how-can-i-find-line-number-of-source-code-for-error/132787/11 "2025-10-01T08:37:45Z")

</div>

Oh I see. `ctrl+q` is better than `ctrl + click`, the latter cannot open  
` @ Base .\tuple.jl:168`  
(I don’t know why). But `ctrl + q` can indeed goto there.

---

<div class="post-metadata">

### Author: ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)
#### Post date: [October 1, 2025, 1:15pm UTC](https://discourse.julialang.org/t/how-can-i-find-line-number-of-source-code-for-error/132787/12 "2025-10-01T13:15:28Z")

</div>

> [@psalm1750](#):
>
> Here, I attached tiny sample file for your reference.  
> It has an error at line=2.  
> But it seems to report at line=6.

The stack trace, which you see below the error message, is composed of several numbered “frames”, each corresponding to a distinct line from a distinct function. Indeed functions call each other in sometimes complicated ways, so telling you the innermost location isn’t always sufficient. Here for instance the error originates at line 2 (in your function definition), but it was your function call at line 6 that actually triggered it.  
As for the color, you should be able to change the color scheme of your terminal to something more visible?

---

<div class="post-metadata">

### Author: ![psalm1750](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/psalm1750/32/210992_2.png) [@psalm1750](https://discourse.julialang.org/u/psalm1750)
#### Post date: [October 1, 2025, 2:18pm UTC](https://discourse.julialang.org/t/how-can-i-find-line-number-of-source-code-for-error/132787/13 "2025-10-01T14:18:55Z")

</div>

Hi gdalle, thank you for your quick and appropriate reply, and I agree with you in terms of terminal color.  
May be I should set “julia --color=no” option.
