Setting the PATH variable from within julia

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! :slightly_smiling_face:

1 Like

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 is very easy to use and takes care of path handling. I also recommend the documentation of the Julia for VSCode extension.

1 Like

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.

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!

1 Like

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! :grin:

1 Like

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

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

:joy: 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!

1 Like

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

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


CC: @PetrKryslUCSD

1 Like

They could use repl.it :

https://replit.com/languages/julia

1 Like

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.

1 Like

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

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. :slight_smile:

Best wishes,

Niall.

1 Like