Skip to content

Commit 67e865b

Browse files
authored
docs: Add Claude Code remote environment setup instructions (#4246)
1 parent ba513e7 commit 67e865b

File tree

1 file changed

+100
-1
lines changed

1 file changed

+100
-1
lines changed

CLAUDE.md

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,108 @@ This document provides essential information for working with the sqlc codebase,
77
### Prerequisites
88

99
- **Go 1.25.0+** - Required for building and testing
10-
- **Docker & Docker Compose** - Required for integration tests with databases
10+
- **Docker & Docker Compose** - Required for integration tests with databases (local development)
1111
- **Git** - For version control
1212

13+
## Claude Code Remote Environment Setup
14+
15+
When running in the Claude Code remote environment (or any environment without Docker), you can install PostgreSQL and MySQL natively. The test framework automatically detects and uses native database installations.
16+
17+
### Step 1: Configure apt Proxy (Required in Remote Environment)
18+
19+
The Claude Code remote environment requires an HTTP proxy for apt. Configure it:
20+
21+
```bash
22+
bash -c 'echo "Acquire::http::Proxy \"$http_proxy\";"' | sudo tee /etc/apt/apt.conf.d/99proxy
23+
```
24+
25+
### Step 2: Install PostgreSQL
26+
27+
```bash
28+
sudo apt-get update
29+
sudo apt-get install -y postgresql
30+
sudo service postgresql start
31+
```
32+
33+
Configure PostgreSQL for password authentication:
34+
35+
```bash
36+
# Set password for postgres user
37+
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"
38+
39+
# Enable password authentication for localhost
40+
echo 'host all all 127.0.0.1/32 md5' | sudo tee -a /etc/postgresql/16/main/pg_hba.conf
41+
sudo service postgresql reload
42+
```
43+
44+
Test the connection:
45+
46+
```bash
47+
PGPASSWORD=postgres psql -h 127.0.0.1 -U postgres -c "SELECT 1;"
48+
```
49+
50+
### Step 3: Install MySQL 9
51+
52+
MySQL 9 is required for full test compatibility (includes VECTOR type support). Download and install from Oracle:
53+
54+
```bash
55+
# Download MySQL 9 bundle
56+
curl -LO https://dev.mysql.com/get/Downloads/MySQL-9.1/mysql-server_9.1.0-1ubuntu24.04_amd64.deb-bundle.tar
57+
58+
# Extract packages
59+
mkdir -p /tmp/mysql9
60+
tar -xf mysql-server_9.1.0-1ubuntu24.04_amd64.deb-bundle.tar -C /tmp/mysql9
61+
62+
# Install packages (in order)
63+
cd /tmp/mysql9
64+
sudo dpkg -i mysql-common_*.deb \
65+
mysql-community-client-plugins_*.deb \
66+
mysql-community-client-core_*.deb \
67+
mysql-community-client_*.deb \
68+
mysql-client_*.deb \
69+
mysql-community-server-core_*.deb \
70+
mysql-community-server_*.deb \
71+
mysql-server_*.deb
72+
73+
# Make init script executable
74+
sudo chmod +x /etc/init.d/mysql
75+
76+
# Initialize data directory and start MySQL
77+
sudo mysqld --initialize-insecure --user=mysql
78+
sudo /etc/init.d/mysql start
79+
80+
# Set root password
81+
mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'mysecretpassword'; FLUSH PRIVILEGES;"
82+
```
83+
84+
Test the connection:
85+
86+
```bash
87+
mysql -h 127.0.0.1 -u root -pmysecretpassword -e "SELECT VERSION();"
88+
```
89+
90+
### Step 4: Run End-to-End Tests
91+
92+
With both databases running, the test framework automatically detects them:
93+
94+
```bash
95+
# Run all end-to-end tests
96+
go test --tags=examples -timeout 20m ./internal/endtoend/...
97+
98+
# Run example tests
99+
go test --tags=examples -timeout 20m ./examples/...
100+
101+
# Run the full test suite
102+
go test --tags=examples -timeout 20m ./...
103+
```
104+
105+
The native database support (in `internal/sqltest/native/`) automatically:
106+
- Detects running PostgreSQL and MySQL instances
107+
- Starts services if installed but not running
108+
- Uses standard connection URIs:
109+
- PostgreSQL: `postgres://postgres:[email protected]:5432/postgres?sslmode=disable`
110+
- MySQL: `root:mysecretpassword@tcp(127.0.0.1:3306)/mysql`
111+
13112
### Running Tests
14113

15114
#### Basic Unit Tests (No Database Required)

0 commit comments

Comments
 (0)