Dependencies
The Sourcegraph codebase requires a few dependencies to be installed in order to run locally. We recommend and support a default approach that is suited for everyone, regardless of their familiarity with the topic.
Databases
macOS
Using Homebrew (recommended!)
brew install postgres redisbrew services start postgresqlbrew services start redis
Using packaged applications
Requirements:
- The
github.com/sourcegraph/sourcegraphrepository cloned in a folder of your choice.
Instructions:
- Install Postgres.app:
- Open your browser and navigate to this page: https://postgresapp.com
- Follow the installation instructions.
- Install Redis.app:
- Open your browser and navigate to this page: https://jpadilla.github.io/redisapp/
- Click on the Download button and install the app in the archive.
- 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
dockeris installed on your system, you can runsg run redis-postgresto start the databases.
Languages
MacOs
Homebrew (recommended)
brew install go yarnbrew install nodejs
Using asdf for everything
Requirements:
- The
github.com/sourcegraph/sourcegraphrepository cloned in a folder of your choice. Homebrewis installed.
Instructions:
- Open a terminal and type:
brew install asdfecho ' . /opt/homebrew/opt/asdf/libexec/asdf.sh' >> ~/.zshrc:zshasdf version
- this should print something similar to
v0.8.1(the numbers are not important) - if you get
zsh: command not found: asdfthen something did not work.
asdf plugin add golangasdf plugin add yarnasdf plugin add nodejs- We now need to be in the sourcegraph repository folder
cd WHERE_THE_SOURCEGRAPH_FOLDER_IS
- if you are not comfortable with the shell:
- Type
cdin the terminal - Drag and drop the folder containing Sourcegraph code from the Finder to the terminal window.
- Type Enter
- Type
asdf installpushd ..popdgo 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 developers to prefer using nvm to manage nodejs versions.
NVM_VERSION="$(curl https://api.github.com/repos/nvm-sh/nvm/releases/latest | jq -r .name)"curl -L https://raw.githubusercontent.com/nvm-sh/nvm/"$NVM_VERSION"/install.sh -o /tmp/install-nvm.shsh /tmp/install-nvm.shexport NVM_DIR="$HOME/.nvm"[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"cd WHERE_THE_SOURCEGRAPH_FOLDER_ISnvm installnvm use --delete-prefix