# Setting the PATH variable from within julia

**URL:** <https://discourse.julialang.org/t/setting-the-path-variable-from-within-julia/97692>\
**Category:** General Usage\
**Tags:** question\
**Created:** [April 20, 2023, 9:48am UTC](https://discourse.julialang.org/t/setting-the-path-variable-from-within-julia/97692 "2023-04-20T09:48:42Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Niall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niall/32/22517_2.png) [@Niall](https://discourse.julialang.org/u/Niall)\
**Post date:** [April 20, 2023, 9:48am UTC](https://discourse.julialang.org/t/setting-the-path-variable-from-within-julia/97692/1 "2023-04-20T09:48:42Z")

</div>

Hi. I’m writing a julia package to teach julia to my students as a basis for learning maths and physics. I find that particularly students with little computer experience can have great difficulties setting things up for using VSC with julia, and a common problem is that they haven’t inserted julia into the PATH variable so that VSC can call it. At least, that’s my understanding of their problem and the solution - please correct me if you object.

Anyway, as a result, I’m writing a very first unit of the package’s course to help them set things up correctly, and one way of supporting them is to insert the julia binary directory myself into their PATH. Is there a way of doing that?

Any other tips you have to help absolute novices get up and running with julia and VSC would also be very welcome!

Thanks! 🙂

---

<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:** [April 20, 2023, 11:51am UTC](https://discourse.julialang.org/t/setting-the-path-variable-from-within-julia/97692/2 "2023-04-20T11:51:22Z")

</div>

Hi @Niall  
To answer your actual question, the global `ENV` variable is a dictionary with all environment variables, which you can modify from within Julia.  
However, this may not be the best thing to teach your students. For installation purposes, [juliaup](https://github.com/JuliaLang/juliaup) is very easy to use and takes care of path handling. I also recommend the documentation of the [Julia for VSCode](https://www.julia-vscode.org/docs/stable/) extension.

---

<div class="post-metadata">

**Author:** ![Niall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niall/32/22517_2.png) [@Niall](https://discourse.julialang.org/u/Niall)\
**Post date:** [April 20, 2023, 4:23pm UTC](https://discourse.julialang.org/t/setting-the-path-variable-from-within-julia/97692/3 "2023-04-20T16:23:25Z")

</div>

Many thanks, @gdalle. I agree that the Julia for VSCode extension is excellent, however it doesn’t specifically say that you should add julia/bin to the path, yet the extension effectively requires it and the julia installation offers the default option of not doing it. The result is that my students (non-english-speaking computer novices) get into a hopeless muddle at home that I then have to sort out.

I wasn’t actually planning on them inserting the directory themselves. Rather, I’m writing an introductory lab for the course, in which I’d take them through checking whether it’s inserted, and then do it myself at their request if it isn’t. Do I understand correctly that if I change the “PATH” entry in the Base.ENV dictionary, that change propagates out to the operating system?

Best wishes,

Niall.

---

<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:** [April 20, 2023, 4:28pm UTC](https://discourse.julialang.org/t/setting-the-path-variable-from-within-julia/97692/4 "2023-04-20T16:28:59Z")

</div>

I think it should work, but again, to get novices to install Julia, I think juliaup and its automatic path management is your best bet. It’s also what I use to manage several versions of Julia concurrently on the same computer, and I haven’t had to worry about bin subfolders ever since!

---

<div class="post-metadata">

**Author:** ![Niall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niall/32/22517_2.png) [@Niall](https://discourse.julialang.org/u/Niall)\
**Post date:** [April 20, 2023, 4:38pm UTC](https://discourse.julialang.org/t/setting-the-path-variable-from-within-julia/97692/5 "2023-04-20T16:38:11Z")

</div>

OK, thanks very much. I’m a little worried about the overhead of asking them to install another package, but I’ll look into it. You’ve been a great help, thanks! 😁

---

<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:** [April 20, 2023, 4:48pm UTC](https://discourse.julialang.org/t/setting-the-path-variable-from-within-julia/97692/6 "2023-04-20T16:48:18Z")

</div>

If they’re used to Python and already have a distribution on their computer, jill.py might be an interesting alternative: [GitHub - johnnychen94/jill.py: A cross-platform installer for the Julia programming language](https://github.com/johnnychen94/jill.py)

Although I think juliaup is slowly becoming a bit of a standard

---

<div class="post-metadata">

**Author:** ![Niall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niall/32/22517_2.png) [@Niall](https://discourse.julialang.org/u/Niall)\
**Post date:** [April 20, 2023, 4:55pm UTC](https://discourse.julialang.org/t/setting-the-path-variable-from-within-julia/97692/7 "2023-04-20T16:55:51Z")

</div>

😂 I’m afraid these students don’t even know what a directory is, let alone a Python. But I promise I will definitely look into juliaup as soon as the pressure lets up. Thanks!

---

<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:** [April 20, 2023, 5:08pm UTC](https://discourse.julialang.org/t/setting-the-path-variable-from-within-julia/97692/8 "2023-04-20T17:08:20Z")

</div>

Oh I see! Maybe an online solution such as Google Colab or Binder would be better then?

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [April 20, 2023, 8:00pm UTC](https://discourse.julialang.org/t/setting-the-path-variable-from-within-julia/97692/9 "2023-04-20T20:00:59Z")

</div>

If your students are using Windows, I think this project might be a very beginner-friendly way for them to get everything working:

> **[GitHub - PetrKryslUCSD/VSCode\_Julia\_portable: Portable Julia running in VSCode](https://github.com/PetrKryslUCSD/VSCode_Julia_portable)**
>
> Portable Julia running in VSCode. Contribute to PetrKryslUCSD/VSCode\_Julia\_portable development by creating an account on GitHub.

  

CC: @PetrKryslUCSD

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [April 20, 2023, 8:33pm UTC](https://discourse.julialang.org/t/setting-the-path-variable-from-within-julia/97692/10 "2023-04-20T20:33:23Z")

</div>

They could use repl.it :

[https://replit.com/languages/julia](https://replit.com/languages/julia)

---

<div class="post-metadata">

**Author:** ![Niall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niall/32/22517_2.png) [@Niall](https://discourse.julialang.org/u/Niall)\
**Post date:** [April 22, 2023, 9:37am UTC](https://discourse.julialang.org/t/setting-the-path-variable-from-within-julia/97692/11 "2023-04-22T09:37:55Z")

</div>

Many thanks for all the really useful suggestions. However, this course is intended for students that have at present no knowledge of computing, but aims to introduce them to the logic of computational thinking and build up in them a confidence in working with the computer. For that, they need to interact with the computer and set things up for themselves, rather than having things done for them.

At the same time, I agree with Guillaume that it would be dangerous for them to be fiddling around with environment variables themselves. What I am currently planning is that the very first lesson (in the julia console, for which they do not yet need VSC) leads them on a tour of their own computer, showing them where the necessary information is situated, helping them set up a startup.jl file and install VSC, and finally showing them where to find the julia binary in order to enter it in VSC’s julia.executablePath. I think that should work.

---

<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:** [April 22, 2023, 9:59am UTC](https://discourse.julialang.org/t/setting-the-path-variable-from-within-julia/97692/12 "2023-04-22T09:59:14Z")

</div>

Sounds good, but why would they need a startup.jl file at this stage? If it’s just for Revise, the VSCode extension loads it automatically in the built-in Julia REPL

---

<div class="post-metadata">

**Author:** ![Niall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niall/32/22517_2.png) [@Niall](https://discourse.julialang.org/u/Niall)\
**Post date:** [April 22, 2023, 10:45am UTC](https://discourse.julialang.org/t/setting-the-path-variable-from-within-julia/97692/13 "2023-04-22T10:45:05Z")

</div>

True. Until now, I used it as a way for them to define a “sandpit” folder in which they could write programs. Defining the variable “sandpit” in startup.jl enabled them to easily move there within the console from any other directory. However, I have now incorporated that definition into the tutorial’s own configuration file, so I no longer need startup.

I’m finding it really interesting building their knowledge from scratch. It’s my aim that the tutorial’s code is itself simple enough for them to inspect it to see how it uses julia to provide the tutorial environment within which they are working. Your tip about ENV has been very helpful there - thanks. 🙂

Best wishes,

Niall.
