> ## Documentation Index
> Fetch the complete documentation index at: https://cosmos-docs-sync-security-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Install CometBFT

## From Go Package

Install the latest version of CometBFT's Go package:

```sh theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
go install github.com/cometbft/cometbft/cmd/cometbft@latest
```

Install a specific version of CometBFT's Go package:

```sh theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
go install github.com/cometbft/cometbft/cmd/cometbft@v0.38
```

## From Binary

To download pre-built binaries, see the [releases page](https://github.com/cometbft/cometbft/releases).

## From Source

You'll need `go` [installed](https://golang.org/doc/install) and the required
environment variables set, which can be done with the following commands:

```sh theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
echo export GOPATH=\"\$HOME/go\" >> ~/.bash_profile
echo export PATH=\"\$PATH:\$GOPATH/bin\" >> ~/.bash_profile
```

### Get Source Code

```sh theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
git clone https://github.com/cometbft/cometbft.git
cd cometbft
```

### Compile

```sh theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
make install
```

to put the binary in `$GOPATH/bin`, or use:

```sh theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
make build
```

to put the binary in `./build`.

**DISCLAIMER:** The binary of CometBFT is built/installed without the DWARF
symbol table. If you would like to build/install CometBFT with the DWARF
symbol and debug information, remove `-s -w` from `BUILD_FLAGS` in the makefile.

The latest CometBFT is now installed. You can verify the installation by
running:

```sh theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
cometbft version
```

## Reinstall

If you already have CometBFT installed and you make updates, simply run:

```sh theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
make install
```

To upgrade, run:

```sh theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
git pull origin main
make install
```

## Compile with CLevelDB Support

Install [LevelDB](https://github.com/google/leveldb) (minimum version is 1.7).

Install LevelDB with snappy (optional). Below are commands for Ubuntu:

```sh theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
sudo apt-get update
sudo apt install build-essential

sudo apt-get install libsnappy-dev

wget https://github.com/google/leveldb/archive/v1.23.tar.gz && \
  tar -zxvf v1.23.tar.gz && \
  cd leveldb-1.23/ && \
  make && \
  sudo cp -r out-static/lib* out-shared/lib* /usr/local/lib/ && \
  cd include/ && \
  sudo cp -r leveldb /usr/local/include/ && \
  sudo ldconfig && \
  rm -f v1.23.tar.gz
```

Set a database backend to `cleveldb`:

```toml theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
# config/config.toml
db_backend = "cleveldb"
```

To install CometBFT, run:

```sh theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
CGO_LDFLAGS="-lsnappy" make install COMETBFT_BUILD_OPTIONS=cleveldb
```

or run:

```sh theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
CGO_LDFLAGS="-lsnappy" make build COMETBFT_BUILD_OPTIONS=cleveldb
```

which puts the binary in `./build`.
