Dependencies

The sourcegraph codebase requires a few dependencies to be installed in orde to run locally. We recommend and support a default approach that is suited for everyone, regardless of their familiarity with the topic.

It's totally possible to use alternative if you need to: sg checks will still perform correctly, but you're on your own for the installation process: see the alternative instructions section.

Databases

macOS

  1. brew install postgres redis
  2. brew services start postgresql
  3. brew services start redis

Using packaged applications

Requirements:

  • The github.com/sourcegraph/sourcegraph repository cloned in a folder of your choice.

Instructions:

  • Install Postgres.app:
    1. Open your browser and navigate to this page: https://postgresapp.com
    2. Follow the installation instructions.
  • Install Redis.app:
    1. Open your browser and navigate to this page: https://jpadilla.github.io/redisapp/
    2. Click on the Download button and install the app in the archive.
    3. Open a terminal and type: sudo mkdir -p /etc/paths.d && echo /Applications/Redis.app/Contents/Resources/Vendor/redis/bin | sudo tee /etc/paths.d/redisapp

Any OS

Docker

  • Assuming that docker is installed on your system, you can run sg run redis-postgres to start the databases.

Languages

MacOs

  1. brew install go yarn
  2. brew install nodejs

Using asdf for everything

Requirements:

  • The github.com/sourcegraph/sourcegraph repository cloned in a folder of your choice.
  • Homebrew is installed.

Instructions:

  1. Open a terminal and type:
  2. brew install asdf
  3. echo ' . /opt/homebrew/opt/asdf/libexec/asdf.sh' >> ~/.zshrc:
  4. zsh
  5. asdf version
  • this should print something similar to v0.8.1 (the numbers are not important)
  • if you get zsh: command not found: asdf then something did not work.
  1. asdf plugin add golang
  2. asdf plugin add yarn
  3. asdf plugin add nodejs
  4. We now need to be in the sourcegraph repository folder
  5. cd WHERE_THE_SOURCEGRAPH_FOLDER_IS
  • if you are not comfortable with the shell:
    1. Type cd in the terminal
    2. Drag and drop the folder containing Sourcegraph code from the Finder to the terminal window.
    3. Type Enter
  1. asdf install
  2. pushd ..
  3. popd
  4. go version
  • this should print something similar to go version go1.17.1 darwin/arm64

Any OS

Using nvm to install NodeJS

It's common for frontend developpers to prefer using nvm to manage nodejs versions.

  1. NVM_VERSION="$(curl https://api.github.com/repos/nvm-sh/nvm/releases/latest | jq -r .name)"
  2. curl -L https://raw.githubusercontent.com/nvm-sh/nvm/"$NVM_VERSION"/install.sh -o /tmp/install-nvm.sh
  3. sh /tmp/install-nvm.sh
  4. export NVM_DIR="$HOME/.nvm"
  5. [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
  6. cd WHERE_THE_SOURCEGRAPH_FOLDER_IS
  7. nvm install
  8. nvm use --delete-prefix