# Traceback details when using include()

**URL:** <https://discourse.julialang.org/t/traceback-details-when-using-include/42165>\
**Category:** New to Julia\
**Created:** [June 27, 2020, 7:11pm UTC](https://discourse.julialang.org/t/traceback-details-when-using-include/42165 "2020-06-27T19:11:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![billtubbs](https://avatars.discourse-cdn.com/v4/letter/b/67e7ee/32.png) [@billtubbs](https://discourse.julialang.org/u/billtubbs)\
**Post date:** [June 27, 2020, 7:11pm UTC](https://discourse.julialang.org/t/traceback-details-when-using-include/42165/1 "2020-06-27T19:11:26Z")

</div>

I’m a beginner here so might be missing something, but I’ve noticed that when I try to include a file that has a bug in it (into a Jupyter notebook), the traceback details are not that helpful because they don’t show the line number on the included file where the error occurred.

**Example** (file “CartPoleBTEnv.jl” has a syntax error on line 165):

Code in Jupyter cell:

```julia
include("CartPoleBTEnv.jl")

```

Cell output:

```julia
syntax: extra token "not" after end of expression

Stacktrace:
 [1] include at ./boot.jl:326 [inlined]
 [2] include_relative(::Module, ::String) at ./loading.jl:1038
 [3] include(::Module, ::String) at ./sysimg.jl:29
 [4] include(::String) at ./client.jl:403
 [5] top-level scope at In[1]:1

```

Here is the traceback detail if I run the offending file from the command line:

```julia
ERROR: LoadError: syntax: extra token "not" after end of expression
Stacktrace:
[1] include at ./boot.jl:326 [inlined]
[2] include_relative(::Module, ::String) at ./loading.jl:1038
[3] include(::Module, ::String) at ./sysimg.jl:29
[4] exec_options(::Base.JLOptions) at ./client.jl:267
[5] _start() at ./client.jl:436
in expression starting at /Users/billtubbs/cartpole/CartPoleBTEnv.jl:165

```

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [June 28, 2020, 8:59am UTC](https://discourse.julialang.org/t/traceback-details-when-using-include/42165/2 "2020-06-28T08:59:47Z")

</div>

I tried it and I wasn’t able to reproduce your finding.  
I get (near) exactly the same error in a jupyter notebook as in a plain REPL.  
Julia 1.4.1, Windows 10, IJulia and Conda/Jupyter latest version/newly installed here.

---

<div class="post-metadata">

**Author:** ![billtubbs](https://avatars.discourse-cdn.com/v4/letter/b/67e7ee/32.png) [@billtubbs](https://discourse.julialang.org/u/billtubbs)\
**Post date:** [June 28, 2020, 6:07pm UTC](https://discourse.julialang.org/t/traceback-details-when-using-include/42165/3 "2020-06-28T18:07:20Z")

</div>

Thanks @oheil. My versions:

Julia: 1.1.1  
Jupyter notebook server: 6.0.3  
Running on Python: 3.7.7  
Browser: Safari 13.1.1  
OS: Mac OS X 10.14.6

Here is a setup which I can reproduce:

File `test_error.jl` in same folder as notebook contains:

```julia
x = 1 
x not 1

```

Screenshot of Jupyter notebook:

 ![Screen Shot 2020-06-28 at 11.10.52](https://global.discourse-cdn.com/julialang/original/3X/0/c/0cc98caa55128b59fe5b77610e401a23c4bfd345.png)

I’ll try updating my Julia. I only installed it yesterday using `conda install -c conda-forge julia` and it gave me 1.1.1. I will see if I can find a more recent version.

Here is the console output:

```julia
(julia) Bills-Mac-mini-2:cartpole billtubbs$ julia test_error.jl 
ERROR: LoadError: syntax: extra token "not" after end of expression
Stacktrace:
 [1] include at ./boot.jl:326 [inlined]
 [2] include_relative(::Module, ::String) at ./loading.jl:1038
 [3] include(::Module, ::String) at ./sysimg.jl:29
 [4] exec_options(::Base.JLOptions) at ./client.jl:267
 [5] _start() at ./client.jl:436
in expression starting at /Users/billtubbs/cartpole/test_error.jl:2
(julia) Bills-Mac-mini-2:cartpole billtubbs$ which julia
/anaconda3/envs/julia/bin/julia

```

Note: All that is missing from the Jupyter output is the last line:

> `in expression starting at /Users/billtubbs/cartpole/test_error.jl:2`

Can you confirm you see that in your Jupyter notebook?

Other than that could it be a problem with my Jupyter install?

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [June 28, 2020, 6:44pm UTC](https://discourse.julialang.org/t/traceback-details-when-using-include/42165/4 "2020-06-28T18:44:54Z")

</div>

You should download the latest stable version of Julia (1.4.2) directly from

> **[Download Julia](https://julialang.org/downloads/)**
>
> The official website for the Julia Language. Julia is a language that is fast, dynamic, easy to use, and open source. Click here to learn more.

Alternatively you can install it on a Mac using `homebrew`, if you have that installed.

---

<div class="post-metadata">

**Author:** ![Ralph\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ralph_smith/32/10344_2.png) [@Ralph\_Smith](https://discourse.julialang.org/u/Ralph_Smith)\
**Post date:** [June 28, 2020, 6:47pm UTC](https://discourse.julialang.org/t/traceback-details-when-using-include/42165/5 "2020-06-28T18:47:09Z")

</div>

FWIW I see the same problem as the OP, using Julia v1.4.1 on Linux with IJulia v1.21.2. Also using the Jupyter console. Outstanding issue:  
[https://github.com/JuliaLang/IJulia.jl/issues/883](https://github.com/JuliaLang/IJulia.jl/issues/883)

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [June 28, 2020, 6:57pm UTC](https://discourse.julialang.org/t/traceback-details-when-using-include/42165/6 "2020-06-28T18:57:42Z")

</div>

Confirmed. Your example can be reproduced on my setup.  
So, issue above still open.

---

<div class="post-metadata">

**Author:** ![billtubbs](https://avatars.discourse-cdn.com/v4/letter/b/67e7ee/32.png) [@billtubbs](https://discourse.julialang.org/u/billtubbs)\
**Post date:** [June 28, 2020, 7:49pm UTC](https://discourse.julialang.org/t/traceback-details-when-using-include/42165/7 "2020-06-28T19:49:00Z")

</div>

> [@dpsanders](#):
>
> You should download the latest stable version of Julia (1.4.2) directly fro

Thanks. If I do that can I still put it in a conda environment?

---

<div class="post-metadata">

**Author:** ![billtubbs](https://avatars.discourse-cdn.com/v4/letter/b/67e7ee/32.png) [@billtubbs](https://discourse.julialang.org/u/billtubbs)\
**Post date:** [June 28, 2020, 7:59pm UTC](https://discourse.julialang.org/t/traceback-details-when-using-include/42165/8 "2020-06-28T19:59:24Z")

</div>

> [@oheil](#):
>
> Confirmed. Your example can be reproduced on my setup.

Okay so if it’s not just me, then is this maybe normal behaviour in a jupyter notebook?

Note, if the error occurs in the notebook, you don’t get any more useful information:

 ![Screen Shot 2020-06-28 at 12.58.03](https://global.discourse-cdn.com/julialang/original/3X/6/7/67e7890f645d9c69139aa96b83b7be428e6cc585.png)

Dumb question: What does `include()` actually do? Does it effectively move the code into the notebook and then compile it? If so, why would we expect a reference to a line in the original file?
