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 redis
brew services start postgresql
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:
- 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
docker
is installed on your system, you can runsg run redis-postgres
to start the databases.
Languages
MacOs
Homebrew (recommended)
brew install go yarn
brew install nodejs
asdf
for everything
Using Requirements:
- The
github.com/sourcegraph/sourcegraph
repository cloned in a folder of your choice. Homebrew
is installed.
Instructions:
- Open a terminal and type:
brew install asdf
echo ' . /opt/homebrew/opt/asdf/libexec/asdf.sh' >> ~/.zshrc:
zsh
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.
asdf plugin add golang
asdf plugin add yarn
asdf 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
cd
in the terminal - Drag and drop the folder containing Sourcegraph code from the Finder to the terminal window.
- Type Enter
- Type
asdf install
pushd ..
popd
go version
- this should print something similar to
go version go1.17.1 darwin/arm64
Any OS
nvm
to install NodeJS
Using 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.sh
sh /tmp/install-nvm.sh
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
cd WHERE_THE_SOURCEGRAPH_FOLDER_IS
nvm install
nvm use --delete-prefix