Running natively

This page describes the procedure to install and run PrairieLearn without any use of Docker. This means that PrairieLearn is running fully natively on the local OS.

  • Install the prerequisites:

    On macOS, these can be installed with Homebrew. On Linux, these should all be standard packages from the OS distribution.

    On macOS, you should ensure you have installed the XCode command line tools:

    xcode-select --install
  • Clone the latest code:

    git clone https://github.com/PrairieLearn/PrairieLearn.git
    cd PrairieLearn
  • Install all dependencies and transpile local packages:

    # This one command will do everything!
    make deps
    
    # Alternatively, you can run each step individually:
    yarn
    make build
    make python-deps

    On macOS, you may need to first set the following environment variables so that pygraphviz can find the necessary headers:

    export CFLAGS="-I$(brew --prefix graphviz)/include"
    export LDFLAGS="-L$(brew --prefix graphviz)/lib"
  • Make sure the postgres database user exists and is a superuser (these might error if the user already exists):

    psql -c "CREATE USER postgres;"
    psql -c "ALTER USER postgres WITH SUPERUSER;"
  • Run the test suite:

    make test
  • Run the linters:

    make lint # or lint-js for Javascript only, or lint-python for Python only
  • Create the file PrairieLearn/config.json with the path of your local course repository and with the path of a directory into which temporary files will be saved when using the in-browser file editor (edit both paths as needed):

    {
      "courseDirs": ["/Users/mwest/git/pl-tam212", "exampleCourse"],
      "filesRoot": "../filesRoot"
    }
  • Run the server in development mode to automatically restart when changes are detected:

    make dev

    Alternatively, you can build and run the code to more closely mimic what will happen in production environments:

    make build
    make start
  • To stop the server, use Ctrl-C.