# Exucute code in VS Code

**URL:** <https://discourse.julialang.org/t/exucute-code-in-vs-code/48171>\
**Category:** VS Code\
**Created:** [October 11, 2020, 4:49pm UTC](https://discourse.julialang.org/t/exucute-code-in-vs-code/48171 "2020-10-11T16:49:33Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [October 11, 2020, 4:49pm UTC](https://discourse.julialang.org/t/exucute-code-in-vs-code/48171/1 "2020-10-11T16:49:33Z")

</div>

I’m trying to use VS Code, and I got the REPL to run, as well as doing a little bit of arithmatic, but I’m not sure how to run a file.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [October 11, 2020, 5:46pm UTC](https://discourse.julialang.org/t/exucute-code-in-vs-code/48171/2 "2020-10-11T17:46:25Z")

</div>

There’s a little “Play” button on the top right:

![image](https://global.discourse-cdn.com/julialang/original/3X/3/e/3e238d8c98d36c9cba30c9969ff1eb7f181b089e.png)

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [October 11, 2020, 5:49pm UTC](https://discourse.julialang.org/t/exucute-code-in-vs-code/48171/3 "2020-10-11T17:49:01Z")

</div>

I do that, and it runs the debugger. I don’t get any errors, but if I put in something like f(x,y)=x+y, I don’t get f generic function with 2 methods, and when I put f(3,2), I don’t get 5, but I get both if I put them straight in the REPL

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [October 11, 2020, 5:55pm UTC](https://discourse.julialang.org/t/exucute-code-in-vs-code/48171/4 "2020-10-11T17:55:12Z")

</div>

What’s your setting for the result display?

![image](https://global.discourse-cdn.com/julialang/original/3X/3/2/3239d929b4a34f3c7757cca7332d925f6fe35efa.png)

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [October 11, 2020, 5:59pm UTC](https://discourse.julialang.org/t/exucute-code-in-vs-code/48171/5 "2020-10-11T17:59:28Z")

</div>

Also note that if you run a file, it is expected that you only get the output of the last evaluated expression, unlike if you enter the same code line-by-line in the REPL. Example:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/c/9/c9d80a5a613bc97950e4df8b1689cf095d360216.png)

Here I have enabled inline display, and have run the file using Shift+Enter - then all lines are executed, but the only result displayed is that of the last evaluated expression, here `g(2, 3)`

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [October 11, 2020, 6:12pm UTC](https://discourse.julialang.org/t/exucute-code-in-vs-code/48171/6 "2020-10-11T18:12:12Z")

</div>

but if I do the same thing,i it doesn’t show g(2,3), nor do I see the answer on the line in the code, like in your sample.

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [October 11, 2020, 6:14pm UTC](https://discourse.julialang.org/t/exucute-code-in-vs-code/48171/7 "2020-10-11T18:14:06Z")

</div>

do I need to put in a file location in Juno:executable path ?

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [October 11, 2020, 6:46pm UTC](https://discourse.julialang.org/t/exucute-code-in-vs-code/48171/8 "2020-10-11T18:46:32Z")

</div>

Wait I thought this thread is about VSCode, not Juno? Also which setting are you using for results display (the screenshot in my second answer)?

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [October 11, 2020, 7:08pm UTC](https://discourse.julialang.org/t/exucute-code-in-vs-code/48171/9 "2020-10-11T19:08:50Z")

</div>

the second screenshot. As for VS Code, yes I am, but in settings, just above Execution Code in REPL, and Execution Type, is a box labled Executable Path (I guess before I said Juno, sorry).

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [October 11, 2020, 7:50pm UTC](https://discourse.julialang.org/t/exucute-code-in-vs-code/48171/10 "2020-10-11T19:50:13Z")

</div>

If you don’t set an executable path, then it will just default to whatever Julia installation is on your systemwide `PATH` (i.e. the Julia which starts when you just type `julia` into a shell).

But if I understand you correctly you have a working REPL in VSCode, so your problem is not that VSCode can’t find your Julia installation?

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [October 11, 2020, 7:53pm UTC](https://discourse.julialang.org/t/exucute-code-in-vs-code/48171/11 "2020-10-11T19:53:13Z")

</div>

Ok, that’s good, and I thought that was working. Are there any more settings I should look at?

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [October 11, 2020, 7:56pm UTC](https://discourse.julialang.org/t/exucute-code-in-vs-code/48171/12 "2020-10-11T19:56:26Z")

</div>

Sorry I’m not sure I’m following - are things working as expected now?

In principle I guess all settings could be relevant, depending on what you want to do 🙂

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [October 11, 2020, 7:58pm UTC](https://discourse.julialang.org/t/exucute-code-in-vs-code/48171/13 "2020-10-11T19:58:06Z")

</div>

In your example, it has a 6 next to g(2,3), and mine doesn’t. I don’t know why.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [October 11, 2020, 8:00pm UTC](https://discourse.julialang.org/t/exucute-code-in-vs-code/48171/14 "2020-10-11T20:00:27Z")

</div>

That is because I set the display to `inline` in the setting which I showed above, and I executed the code using `Alt+Enter` - see the docs here for different ways to execute code: [Running Code · Julia in VS Code](https://www.julia-vscode.org/docs/stable/userguide/runningcode/)

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [October 11, 2020, 8:02pm UTC](https://discourse.julialang.org/t/exucute-code-in-vs-code/48171/15 "2020-10-11T20:02:19Z")

</div>

I set it to both, and using Alt+Enter, it does exactly that. Thanks!
