Julia Setup and Package Management

Author

Jesse Perla, UBC

TL;DR

  1. Install Git
  2. Install VS Code
  3. Install Julia following the juliaup instructions
    • Windows: winget install julia -s msstore in a terminal
    • Linux/Mac: curl -fsSL https://install.julialang.org | sh in a terminal
  4. Install the VS Code Julia extension

Some Common Julia Installation Errors on MacOS

  • To open a terminal on MacOS

    • Press Cmd + Space to open Spotlight, then type Terminal
    • Or with VS Code <Cmd-Shift-P> then View: Toggle Terminal
  • If you get permissions problems try

    sudo curl -fsSL https://install.julialang.org | sh
  • If it still shows errors, then see here and do some combo of

    sudo chown $(id -u):$(id -g) ~/.bashrc
    sudo chown $(id -u):$(id -g) ~/.zshrc
    sudo chown $(id -u):$(id -g) ~/.bash_profile
    • Then retry sudo curl -fsSL https://install.julialang.org | sh

Package Environment

Julia Environment Basics

  • Project files keep track of dependencies and make things reproducible
    • Similar to Python’s virtual environments but easier to use
  • VS Code and Jupyter will automatically activate a Project.toml
    • In REPL or Jupyter enter ] for managing packages
    • Can manually activate with ] activate or ] activate path/to/project
    • On commandline, can use julia --project
  • With activated project, use ] instantiate to install all the packages
  • For this course: no package management required after instantiation

Reproducibility

  • ALWAYS use a Project.toml file
    • Keep your global environment as clean
  • Associated with Project.toml is a Manifest.toml file which establishes the exact versions for reproducibility
    • ] instantiate will install the exact versions
    • Less important for us, but very useful for reproducibility in research to distribute with project