What is the best way to set the path to julia on Windows 10?

I just installed Julia 1.0.1. I noticed that the executable wasn’t added to path, so I was wondering what is the best way to add julia to path?

I’m using Windows 10.

I thought about simply adding C:\Users\NAME\AppData\Local\Julia-1.0.1\bin\julia.exe because that is what the desktop shortcut is pointing to, but the location has the julia version in it. This means that any time julia is updated, the path will need to be modified again.

  1. Is there any better way to add julia to path?
  2. I did some searching and couldn’t find a lot of information about adding julia to path. Is there some reason it’s not good to have it on path?
1 Like

The windows home directory is not a fun place. To answer question 1: I think you need to adjust the path manually with each update.

Not specifically related to your question, but to make windows a bit less unfriendly I put

cd("C:/julia-home")
push!(LOAD_PATH, "C:/julia-home")

into my startup.jl, and work from there. Others may have better solutions.

1 Like

Here’s a pretty good reason:

Personally I don’t use other software that have these dependencies, so I add Julia’s bin folder to my Windows path anyway (for convenience when working with the Windows command line). I haven’t noticed any side effects in the past year, but YMMV.

2 Likes

Thanks for the responses. There are actually two reasons I want to add julia to path:

  1. If you use the julia shortcut that’s created on the desktop during install, I think it uses powershell. Whatever font is used in powershell doesn’t support all the unicode characters, for example \xor shows up as a box with a question mark in it. There is a different terminal I like to use called Hyper, which supports all the characters and has other features I like. If I want to use Hyper, then I need julia on path so I don’t have to type the full exe path every time.
  2. Even if I use the default powershell version of julia, it is a pain to browse to the desired working directory. @Adriel’s solution will help with that, but I don’t want to be forced to keep anything juila related in a single location. If julia is on path, then I can right click in any folder I want, open up the terminal at that directory, and then just run julia. Otherwise I need to launch julia and browse wherever I want using the terminal, which is much less convenient, especially in a deeply nested folder.
1 Like

An easy way to avoid the need to amend the path with each update is to install Julia in a folder like
c:\Julia-1.X\
Then, when a new version comes out, simply install it in the same folder (preferably after an uninstall of the old version).

1 Like

This is exactly what I do.

However, I only add the path to my powershell profile.

Add the following to Microsoft.Powershell_profile

function julia {C:\tools\Julia\julia-1.x\bin\julia.exe $args}
1 Like

The default installation path is pretty bad, it should try to install to program files , like all other software, or C:\julia

I agree. I can never find anything anymore when it is spread throughout configuration directories, APPDATA, registry, etc.

I might be wrong, but I think the reason things are being installed into local user directories instead of program files is because it gets around system permissions. Some workplaces restrict installations that modify system directories, and rather than having to whitelist a program or get permission, installing it in appdata installs without issues.

True, but that can be an option during installation and same with an unchecked option to add to path (with a warning, similar to git and anaconda installers).

100% Agree. There was a discussion ~4 years ago about this but I don’t remember anymore why devs insisted in installing Julia on that dir. I never let it do so and because I also hate dirs with spaces in their names, for me Julia always go to C:\programs\julia-x.x. Than I call it via a batch file that also sets the path.

1 Like

I know this thread is old, but as a PSA/posterity for people continuing to struggle with this:

Create a new “safe” directory and add it to Windows path (or use an existing one) and put a batch file in your new directory containing:
"C:\path\to\julia.exe" %* and name it “julia.bat” This will sidestep the .dll issue and let you launch julia by just typing it from cmd.exe or powershell. Arguments work too.

1 Like

I just kludged together the following power shell script which may be helpful.

The idea is that you put it in a project folder and can run julia with that folder as the working directory just by double clicking the script file. It automatically finds and uses the latest installed version of julia.

$host.ui.RawUI.WindowTitle = "Julia"

# Use the script directory as the initial working directory
cd $PSScriptRoot

# Find the latest installed version of Julia
$jlpath = dir -Path $Env:LOCALAPPDATA/Julia-* | sort -Property FullName | Select-Object -Last 1 | Join-Path -ChildPath "bin\julia.exe"

# Use current directory as the project directory.
# You may want to remove the --project
iex "$jlpath --project=."

side note… coming from knowing bash quite well, powershell sure is unusual. But ever so much saner than .bat files.

4 Likes

I found leaving the julia.exe off at the end of the path worked:
C:\Users\your-user-name\AppData\Local\Julia-1.3.1\bin\

When leaving …\julia.exe on the path in Windows 10, it would not recognize it at all. Just ending it with …\bin, when I tried again in Powershell, it worked. Hope this works for the next person who comes upon this discussion someday :wink:

2 Likes