> ## Documentation Index
> Fetch the complete documentation index at: https://developers.chatwoot.com/llms.txt
> Use this file to discover all available pages before exploring further.

# macOS Development Setup

> Complete guide to setting up your macOS development environment for Chatwoot contribution.

# macOS Development Setup

This guide will help you set up your macOS development environment for contributing to Chatwoot. Open Terminal app and run the following commands.

## Installing the Standalone Command Line Tools

Open Terminal app and run:

```bash theme={null}
xcode-select --install
```

This installs essential development tools including Git, GCC, and other command line utilities.

## Install Homebrew

Homebrew is the missing package manager for macOS:

```bash theme={null}
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
```

After installation, add Homebrew to your PATH (if not automatically added):

```bash theme={null}
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
```

## Install Git

```bash theme={null}
brew update
brew install git
```

Configure Git with your information:

```bash theme={null}
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
```

## Install Ruby Version Manager

Choose between RVM or rbenv for managing Ruby versions.

### Option 1: Install RVM (Recommended)

```bash theme={null}
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
```

### Option 2: Install rbenv (Alternative)

```bash theme={null}
brew install rbenv ruby-build
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
source ~/.zshrc
```

## Install Ruby

Chatwoot APIs are built on Ruby on Rails. You need to install Ruby 3.2.2.

### If using RVM:

```bash theme={null}
rvm install ruby-3.2.2
rvm use 3.2.2 --default
source ~/.rvm/scripts/rvm
```

### If using rbenv:

```bash theme={null}
rbenv install 3.2.2
rbenv global 3.2.2
```

<Info>
  rbenv identifies the ruby version from `.ruby-version` file on the root of the project and loads it automatically.
</Info>

Verify Ruby installation:

```bash theme={null}
ruby --version
# Should output: ruby 3.2.2
```

## Install Node.js

Chatwoot requires Node.js version 20:

```bash theme={null}
brew install node@20
```

If you need to link Node.js 20:

```bash theme={null}
brew link node@20
echo 'export PATH="/opt/homebrew/opt/node@20/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
```

Verify Node.js installation:

```bash theme={null}
node --version
# Should output: v20.x.x
```

## Install pnpm

We use `pnpm` as our package manager for better performance:

```bash theme={null}
brew install pnpm
```

Verify pnpm installation:

```bash theme={null}
pnpm --version
```

## Install PostgreSQL

The database used in Chatwoot is PostgreSQL.

### Option 1: PostgresApp (Recommended)

1. Download and install PostgresApp from [https://postgresapp.com](https://postgresapp.com)
2. This is the easiest way to get started with PostgreSQL on macOS
3. Follow the setup instructions on their website

### Option 2: Homebrew Installation

```bash theme={null}
brew install postgresql@14
```

Start PostgreSQL service:

```bash theme={null}
brew services start postgresql@14
```

Create a PostgreSQL user:

```bash theme={null}
createuser -s postgres
```

Connect to PostgreSQL to verify installation:

```bash theme={null}
psql postgres
# Type \q to exit
```

## Install Redis Server

Chatwoot uses Redis server for agent assignments and reporting:

```bash theme={null}
brew install redis
```

Start the Redis service:

```bash theme={null}
brew services start redis
```

Verify Redis installation:

```bash theme={null}
redis-cli ping
# Should output: PONG
```

## Install ImageMagick

Chatwoot uses ImageMagick library to resize images for previews and thumbnails:

```bash theme={null}
brew install imagemagick
```

Verify ImageMagick installation:

```bash theme={null}
convert --version
```

## Install Additional Dependencies

Install other useful development tools:

```bash theme={null}
# Install Yarn (alternative to pnpm if needed)
brew install yarn

# Install SQLite (for testing)
brew install sqlite

# Install libvips (for image processing)
brew install libvips
```

## Install Docker (Optional)

For development and testing with containers:

```bash theme={null}
# Install Docker Desktop
brew install --cask docker
```

Or download Docker Desktop from [https://www.docker.com/products/docker-desktop/](https://www.docker.com/products/docker-desktop/).

## Environment Verification

Verify all installations are working:

```bash theme={null}
# Check versions
ruby --version        # Should be 3.2.2
node --version         # Should be v20.x.x
pnpm --version        # Should show pnpm version
psql --version        # Should show PostgreSQL version
redis-cli --version   # Should show Redis version
convert --version     # Should show ImageMagick version
git --version         # Should show Git version
```

## Configure Shell Environment

Add useful aliases to your shell configuration file (`~/.zshrc` for Zsh):

```bash theme={null}
# Add to ~/.zshrc
echo '# Chatwoot Development Aliases' >> ~/.zshrc
echo 'alias cw-server="bundle exec rails server"' >> ~/.zshrc
echo 'alias cw-console="bundle exec rails console"' >> ~/.zshrc
echo 'alias cw-test="bundle exec rspec"' >> ~/.zshrc
echo 'alias cw-migrate="bundle exec rails db:migrate"' >> ~/.zshrc

# Reload shell configuration
source ~/.zshrc
```

## Troubleshooting Common Issues

<Accordion title="Command line tools installation fails">
  **Solution**: Update macOS to the latest version and try again. You can also download Xcode from the App Store.
</Accordion>

<Accordion title="Homebrew installation permission errors">
  **Solution**:

  ```bash theme={null}
  sudo chown -R $(whoami) /opt/homebrew
  ```
</Accordion>

<Accordion title="Ruby installation fails with RVM">
  **Solution**:

  ```bash theme={null}
  # Install missing dependencies
  brew install openssl readline libyaml
  rvm reinstall 3.2.2 --with-openssl-dir=$(brew --prefix openssl)
  ```
</Accordion>

<Accordion title="PostgreSQL connection refused">
  **Solution**:

  ```bash theme={null}
  # Restart PostgreSQL
  brew services restart postgresql@14

  # Check if it's running
  brew services list | grep postgresql
  ```
</Accordion>

<Accordion title="ImageMagick installation issues">
  **Solution**:

  ```bash theme={null}
  # If you encounter issues, try:
  brew uninstall imagemagick
  brew install imagemagick
  ```
</Accordion>

## Getting Help

If you encounter issues:

* **Common Errors**: Check [Common Errors](/contributing-guide/common-errors)
* **Discord Community**: Join our [Discord](https://discord.com/invite/cJXdrwS)
* **GitHub Issues**: [Create an issue](https://github.com/chatwoot/chatwoot/issues)

***

Your macOS development environment is now ready for Chatwoot development! 🚀
