# Wrong path aggregation with \`include\` under vscode - terminal session is fine

**URL:** <https://discourse.julialang.org/t/wrong-path-aggregation-with-include-under-vscode-terminal-session-is-fine/71985>\
**Category:** VS Code\
**Tags:** path\
**Created:** [November 23, 2021, 11:14pm UTC](https://discourse.julialang.org/t/wrong-path-aggregation-with-include-under-vscode-terminal-session-is-fine/71985 "2021-11-23T23:14:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![reumle](https://avatars.discourse-cdn.com/v4/letter/r/5daacb/32.png) [@reumle](https://discourse.julialang.org/u/reumle)\
**Post date:** [November 23, 2021, 11:14pm UTC](https://discourse.julialang.org/t/wrong-path-aggregation-with-include-under-vscode-terminal-session-is-fine/71985/1 "2021-11-23T23:14:03Z")

</div>

hi Path aggregation seems to have declared independence from my instructions. Here the problem (with vscode Repl)

### The bad behavior

```julia-auto
julia> cd("C:\\proj\\Rprojs\\PS1908\\julia\\21T4_vormdp")
       using Pkg
       Pkg.activate(".")
  Activating environment at `C:\proj\Rprojs\PS1908\julia\21T4_vormdp\Project.toml`

julia> pwd()
"C:\\proj\\Rprojs\\PS1908\\julia\\21T4_vormdp"

julia> include("./src/orders.jl")
ERROR: LoadError: SystemError: opening file "c:\\proj\\Rprojs\\PS1908\\julia\\21T4_vormdp\\mains\\src\\orders.jl": No such file or directory
Stacktrace:
  [1] systemerror(p::String, errno::Int32; extrainfo::Nothing)
    @ Base .\error.jl:168

```

- the `include` instruction should try to open the combination of

- but instead it tries to open a different file..`c:\\proj\\Rprojs\\PS1908\\julia\\21T4_vormdp\\mains\\src\\orders.jl`

### The same from a terminal session- works fine.

```julia-auto
PS C:\proj\Rprojs\PS1908\julia\21T4_vormdp> julia
               _
   _ _ _(_)_ | Documentation: https://docs.julialang.org
  (_) | (_) (_) |
   _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` | |
  | | |_| | | | (_| | | Version 1.6.1 (2021-04-23)
 _/ |\ __'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |

julia> cd("C:\\proj\\Rprojs\\PS1908\\julia\\21T4_vormdp")

julia> using Pkg

julia> Pkg.activate(".")
  Activating environment at `C:\proj\Rprojs\PS1908\julia\21T4_vormdp\Project.toml`       

julia> pwd()
"C:\\proj\\Rprojs\\PS1908\\julia\\21T4_vormdp"

julia> include("./src/orders.jl")
Main.orders

```

- Would you know about this? Does vscode maintain a separate “current” directory? like a “shadow” `pwd`?

---

<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 24, 2021, 8:10am UTC](https://discourse.julialang.org/t/wrong-path-aggregation-with-include-under-vscode-terminal-session-is-fine/71985/2 "2021-11-24T08:10:56Z")

</div>

How did you run the `include("./src/orders.jl")` line? Via inline evaluation or by typing it into the REPL?

---

<div class="post-metadata">

**Author:** ![reumle](https://avatars.discourse-cdn.com/v4/letter/r/5daacb/32.png) [@reumle](https://discourse.julialang.org/u/reumle)\
**Post date:** [November 24, 2021, 9:20pm UTC](https://discourse.julialang.org/t/wrong-path-aggregation-with-include-under-vscode-terminal-session-is-fine/71985/3 "2021-11-24T21:20:53Z")

</div>

Nice catch! It was indeed via inline evaluation. Here below a vscode REPL session using `include` 3 times:

- first by direct typing (success, `include` works),
- then by inline evaluation (error)
- then by typing again (success).

This gives an obvious workaround. Do you also know an easy fix to the “inline” way?

Thank you!

````julia
julia> cd("C:\\proj\\Rprojs\\PS1908\\julia\\21T4_vormdp")

julia> using Pkg

julia> Pkg.activate(".")
  Activating environment at `C:\proj\Rprojs\PS1908\julia\21T4_vormdp\Project.toml`

julia> include("./src/orders.jl") # direct typing
Main.orders

julia> 

julia> include("./src/orders.jl") #inline
ERROR: LoadError: SystemError: opening file "c:\\proj\\Rprojs\\PS1908\\julia\\21T4_vormdp\\mains\\src\\orders.jl": No such file or directory    
Stacktrace:
  [1] systemerror(p::String, errno::Int32; extrainfo::Nothing)
    @ Base .\error.jl:168
  [2] #systemerror#62
    @ .\error.jl:167 [inlined]
  
[..snipped...]

julia> include("./src/orders.jl") # direct typing
WARNING: replacing module orders.
Main.orders

```
````

---

<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 25, 2021, 8:12am UTC](https://discourse.julialang.org/t/wrong-path-aggregation-with-include-under-vscode-terminal-session-is-fine/71985/4 "2021-11-25T08:12:23Z")

</div>

I’d say this is working as intended and there’s nothing to fix there 🙂

Generally, Julia will resolve `include`s relative to `@ __DIR__ `, which is the directory of whatever file you’re in – unless you’re using the REPL, in which case it’s relative to `pwd()`.

So you really should make sure to specify `include` paths that way to make sure your file works fine when calling it with e.g. `julia main.jl`.

---

<div class="post-metadata">

**Author:** ![reumle](https://avatars.discourse-cdn.com/v4/letter/r/5daacb/32.png) [@reumle](https://discourse.julialang.org/u/reumle)\
**Post date:** [November 25, 2021, 6:55pm UTC](https://discourse.julialang.org/t/wrong-path-aggregation-with-include-under-vscode-terminal-session-is-fine/71985/5 "2021-11-25T18:55:07Z")

</div>

Indeed that’s it exactly!  
Thank you!
