This article contains affiliate links. See my affiliate disclosure for more information.



Need to get up and running with Julia fast?

This guide walks you through setting up a professional Julia development environment step-by-step. You'll learn how to:

  • Install Julia with juliaup.
  • Set up the Julia VS Code extension.
  • Create a shared dev environment with common development tools.
  • Write a startup.jl file to automatically load the shared environment every time Julia launches.

Open up your terminal, and let's dive in.

✉️
This article was originally published in my Curious About Code newsletter. Never miss an issue. Subscribe here →

Install Julia With juliaup

You could download a Julia binary from julialang.org, but that's boring.

All the cool kids use juliaup, a Julia "version multiplexer" inspired by the rustup project. With juliaup, you can install multiple Julia versions and switch between them from the command line. It'll even notify you in your terminal when a new Julia version is available.

To install juliaup, execute the command below that corresponds to your operating system:

macOS/Linux:

curl -fsSL https://install.julialang.org | sh

Windows:

winget install julia -s msstore

Run juliaup status to see every Julia version installed by juliaup. The latest version is already installed:

$ juliaup status
 Default  Channel  Version                         Update
----------------------------------------------------------
       *  release  1.8.5+0.aarch64.apple.darwin14

You can learn more about juliaup from the project's README on GitHub.


Set Up The Julia VS Code Extension

You can use Julia with your preferred code editor. But if you want an IDE experience, your best option is VS Code. The same folks behind juliaup maintain the official Julia VS Code extension.

Download and install VS Code if you haven't already. Then, open VS Code and click on the Extensions tab in the Activity Bar:

Type julia into the search bar. The first result should be the official Julia extension, published by a verified account named julialang:

Click on Install to install the extension:

Unless you changed the location of your Julia install with juliaup — something that isn't covered in this guide — the extension will find Julia automatically.

To test this, create a hello_world.jl file somewhere on your computer, open it with VS Code, add the line print("Hello, world") and save the file, then press the play button in the top right-hand corner of the window:

VS Code executes the script and displays the output in a new Julia REPL window at the bottom of the editor window.

☝️
Note: If VS Code can't find Julia, you may need to point it to the correct install location by changing the julia.executablePath setting. See the Julia VS Code extension docs for more information.

The Julia VS Code extension provides language support, Intellisense, linting and formatting tools, and everything else you need to dive into your first Julia project.




Advanced: Create A Shared Dev Environment

The Julia ecosystem has some fantastic developer productivity tools, including:

  • Revise.jl for using code changes from the REPL without restarting Julia.
  • OhMyREPL.jl for REPL syntax highlighting and bracket matching.
  • BenchmarkTools.jl for performance tracking and benchmark analysis.

These three packages turn the Julia REPL into a simple-yet-powerful development environment. It'd be great if you could access these tools no matter which project you're working on. Thanks to Julia's support for stacked environments, you can.

Start by creating a new directory somewhere for the dev tools environment. I keep mine in a folder called ~/.julia-environments/tools/. Then cd into this directory and run Julia:

$ mkdir -p ~/.julia-environments/tools
$ cd ~/.julia-environments/tools
$ julia

After the REPL starts, press ] to enter the package manager mode:

julia> ]
(@v1.8) pkg>

The (@v1.8) to the left of pkg> indicates the base (or global) environment for Julia version 1.8 is currently active. You may see a different version number.

☝️
Note: Thanks to Julia's default environment loading process, you can install packages in the global environment and automatically have access to them in every project.

There are two reasons I don't do this:

1. I've been conditioned by years of Python programming to avoid global environments.

2. Julia's global environment lives in ~/.julia/environments/, which is managed by Julia itself. I want my tools environment to live somewhere I know it won't suddenly change (and I can version control).

Create a new environment in the current directory by executing activate . in the REPL:

(@v1.8) pkg> activate .
  Activating new project at `~/.julia-enironments/tools`

(tools) pkg>

Use the add command to install the Revise, OhMyREPL, and BenchmarkTools packages:

(tools) pkg> add Revise OhMyREPL BenchmarkTools
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
    Updating `~/.julia-enironments/tools/Project.toml`
  [6e4b80f9] + BenchmarkTools v1.3.2
  [5fb14364] + OhMyREPL v0.5.13
  [295af30f] + Revise v3.5.0
    Updating `~/.julia-enironments/tools/Manifest.toml`
  [6e4b80f9] + BenchmarkTools v1.3.2
  [da1fd8a2] + CodeTracking v1.2.0
  [a8cc5b0e] + Crayons v4.1.1

  ... (output truncated)
  
(tools) pkg>

Two files are created in the ~/.julia-environment/tools/ directory:

  • Project.toml contains the names and hashes for the three packages you installed with the add command.
  • Manifest.toml describes the fully-resolved dependency graph for the packages in Project.toml.

Together, the ~/.julia-environments/tools/ directory and Project.toml and Manifest.toml files formally define a Julia environment. But you'll have to explicitly activate the environment each time you want to use it.

Let's change that.


Advanced: Write a startup.jl File

Press Ctrl + D to close the Julia REPL. Then, cd into the ~/.julia/ directory. ~/.julia/ was created automatically when you installed Julia with juliaup. It contains, among other things, global environments, package registries, logs, and configuration files.

Create a file ~/.julia/config/startup.jl with the following contents (cheers to Tim Holy for including a template for loading packages in startup.jl in the Revise.jl docs):

# ~/.julia/config/startup.jl

# Stack the tools environment on top of the currently active environment.
# See: https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_LOAD_PATH
# Remove the line below if you installed tools in your global environment
push!(LOAD_PATH, Base.Filesystem.homedir() * "/.julia-environments/tools/")

# Import the tools, or display a warning if something goes wrong
try
    @eval using OhMyREPL
catch e
    @warn "Error initializing OhMyREPL" exception=(e, catch_backtrace())
end

try
    @eval using Revise
catch e
    @warn "Error initializing Revise" exception=(e, catch_backtrace())
end

try
    @eval using BenchmarkTools
catch e
    @warn "Error initializing BenchmarkTools" exception=(e, catch_backtrace())
end
☝️
Note: You may need to create the ~/.julia/config/ directory on a fresh Julia install.

Now, every time you start Julia — even from VS Code — Revise, OhMyREPL, and BenchmarkTools are safely and automatically loaded on top of the active environment without having to install and import them in every project.

Pretty nifty if you ask me!


Other startup.jl Packages

Here are a few other handy packages to consider installing in your tools environment and importing in your startup.jl file:

And don't miss this long-running thread on the Julia Discourse with many other use cases for startup.jl.


Dig Deeper

If you're interested in getting started with Julia to work with data, I highly recommend Bogumił Kamiński's book Julia For Data Analysis. It's also got one of the best introductions to Julia for experienced programmers I've seen.

Get instant access from Manning. A Kindle version is available from Amazon.

▶️
Learn more: I interviewed Bogumił about Julia For Data Analysis in 2022 for the Talk Julia podcast. Watch the video here →