Working on Tina4 on Windows#
This page is for the next person who works on the four frameworks (tina4-python, tina4-php, tina4-ruby and tina4-nodejs) from a Windows machine. Everything here was found by running all four full suites on a Windows 11 box against real services, and most of it was found the hard way.
You'll need three things before a suite will run: the lab (every service the suites talk to, in Docker), one of the two ways to run a suite, and the rules for sharing a machine with other people's runs. The gotchas table at the end will save you a few evenings.
Two ways to run the suites#
| Native Windows | WSL Ubuntu | |
|---|---|---|
| What it proves | The framework works on Windows | The suite passes the way continuous integration (CI) runs it |
| Status | Best effort: some cases skip with a [needs:...] tag | Recommended for a full run before you call a change green |
| POSIX-only tests (fork, signals, symlinks, file modes, PTY) | Skipped and tagged | Run |
| Services | The lab, on 127.0.0.1 | The same lab, also on 127.0.0.1 |
Run in Windows Subsystem for Linux (WSL) when you want CI's answer on your own machine. Run natively when your change touches anything that behaves differently on Windows: processes, ports, paths, pipes, line endings.
Native Windows (best effort)#
These toolchain versions ran the full suites:
| Framework | Toolchain that worked |
|---|---|
| Python | Python 3.14 with uv |
| PHP | PHP 8.4, the Zend Thread Safety (ZTS) x64 build |
| Ruby | Ruby 3.3.10 from RubyInstaller (x64-mingw-ucrt), with its MSYS2 devkit |
| Node | Node 25 |
Start the lab and source its env first (see The lab). Then, in the framework checkout:
# Pythonuv sync --extra testuv run pytest tests/โ# PHP (memory_limit=-1 is already set in phpunit.xml)composer installvendor/bin/phpunitโ# Ruby (see the Ruby rows in the gotchas table for the client libraries)bundle config set --local without kafkabundle config set --local with databases:mysql:odbc:nats:firebirdbundle installbundle exec rspecโ# Nodenpm cinpx tsx test/run-all.tsnpm run typecheckAlways run Ruby under bundle exec. A bare ruby -S rspec picks the newest installed commonmarker, whose Windows binary doesn't load on Ruby 3.3, and then openapi3_parser looks missing.
What to expect on a native run. Each framework's plan/windows-test-suite.md on v3 has the full record:
| Framework | Last native run with the lab |
|---|---|
| Python | 10804 passed, 0 failed, 126 skipped (every skip tagged), 43m |
| PHP | 7518 tests, 0 failures, 131 skipped, 44m; 27 graph cases wait on a driver decision |
| Ruby | not green yet: host prerequisites (Developer Mode, the client libraries) |
| Node | 24213 passed, 0 failed, 42 skipped (every skip tagged), 47m |
The skips that stay on Windows are machine-readable: [needs:os=posix], [needs:posix-signals], [needs:symlink-privilege], [needs:odbc-driver] and so on. Each one names what the Linux pass supplies.
WSL Ubuntu (recommended: matches CI)#
The lab stays in Docker Desktop. WSL reaches it on 127.0.0.1, exactly as Windows does, as long as Docker Desktop's WSL integration is on for your distro.
One-time installs (Ubuntu 24.04, needs sudo)#
Build tools, and the native client libraries the repos' CI workflows install:
sudo apt-get updatesudo apt-get install -y build-essential git curl unzipsudo apt-get install -y unixodbc unixodbc-dev odbc-postgresql libfbclient2 firebird-dev \ librdkafka-dev default-libmysqlclient-dev freetds-dev libpq-devPHP 8.4 from the ondrej Personal Package Archive (PPA):
sudo apt-get install -y software-properties-commonsudo add-apt-repository -y ppa:ondrej/phpsudo apt-get updatesudo apt-get install -y php8.4-cli php8.4-mbstring php8.4-xml php8.4-curl php8.4-zip \ php8.4-sqlite3 php8.4-pgsql php8.4-mysql php8.4-sybase php8.4-redis php8.4-memcached \ php8.4-mongodb php8.4-intl php8.4-bcmath php8.4-gd php8.4-odbc php8.4-interbase \ php8.4-imap unzip composersudo update-alternatives --set php /usr/bin/php8.4php -v | head -1 # must say 8.4php8.4-sybase (pdodblib) is required, not optional: PHP's Linux CI disables sqlsrv, so the live MSSQL tests run on pdodblib over FreeTDS. lab/wsl-test also checks for imap. The update-alternatives step matters because Ubuntu's composer package can pull in a newer PHP from the PPA and repoint php at it.
Ruby 3.3.10 through rbenv and ruby-build:
# Ruby's own build deps; the gems' client libraries came with the line abovesudo apt-get install -y libssl-dev libyaml-dev zlib1g-dev libffi-dev libreadline-devgit clone https://github.com/rbenv/rbenv.git ~/.rbenvgit clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-buildecho 'eval "$(~/.rbenv/bin/rbenv init - bash)"' >> ~/.bashrcexec bashrbenv install 3.3.10rbenv global 3.3.10gem install bundlerPython with uv, from Astral's installer:
curl -LsSf https://astral.sh/uv/install.sh | shNode: CI runs Node 22. Use NodeSource's 22.x repository if the distro doesn't have it.
Running a suite in WSL#
Keep the clones on the Linux filesystem (~/...), never on /mnt/c. The 9p bridge is slow, and a Windows checkout carries CRLF line endings and loses exec bits and symlinks.
mkdir -p ~/tina4-test && cd ~/tina4-testgit clone https://github.com/tina4stack/tina4-python.gitcd tina4-python && git checkout v3โ# keep package caches in the real home: lab-env.sh moves HOME nextexport UV_CACHE_DIR=~/.cache/uv npm_config_cache=~/.npm COMPOSER_HOME=~/.config/composer. /mnt/c/<path-to>/tina4-documentation/lab/lab-env.sh pythonโuv sync --extra test && uv run pytest tests/# php: composer install && vendor/bin/phpunit# ruby: bundle config set --local with databases:mysql:odbc:firebird && bundle install && bundle exec rspec# nodejs: npm ci && npm testIf you source lab-env.sh from a different checkout than the one that ran lab/up, point TINA4_LAB_STATE at that checkout's lab/.state first, so the suites find the lab's certificate authority.
WSL adds the Windows PATH to its own. A missing Linux composer or bundle will quietly resolve to the Windows one under /mnt/c/... and fail in odd ways. Check command -v composer bundle php ruby before you trust a run.
lab/wsl-test: one command per suite#
lab/wsl-test (tina4-documentation#246) does all of the above for you:
# inside WSL, from the tina4-documentation checkoutbash lab/wsl-test <python|php|ruby|nodejs> [ref] [extra test-runner args]bash lab/wsl-test php fix/my-branchbash lab/wsl-test ruby pr/412 spec/orm_spec.rb# from Windowspowershell -ExecutionPolicy Bypass -File lab\wsl-test.ps1 nodejs v3ref is a branch, tag, commit or pr/<n> in the framework's GitHub repo, and it defaults to v3. Push your branch first: the runner tests its own clone, not your Windows worktree. Then it:
- refuses to start, naming the fix, when a toolchain, a PHP extension or a CI client package is missing, or when the lab isn't answering. It ignores Windows binaries on the
PATHand never installs anything system-level; - keeps a WSL-native clone per repo in
~/tina4-test/<repo>, checks out the ref detached and resets it withgit clean, keeping.venv,vendor,node_modulesand.bundle; - fetches CI's pinned native
tina4CLI (the Rust client), checks it against the release'sSHA256SUMS, keeps it in~/tina4-test/binand puts it first onPATH. The~/.local/bin/tina4you may already have in WSL is tina4-python's pip console script, a different program, and the metrics and CLI-handoff tests fail on it with "Unknown command"; - sources
lab-env.sh <framework>, installs the way CI does, runs the full suite, tees the log to~/tina4-test/logs/and ends with== SUMMARY <fw> @ <sha> (<ref>): .... The exit status is the suite's.
Never rm -rf inside WSL#
/mnt/c is the whole Windows drive. One empty variable in rm -rf "$DIR/" wipes Windows files and other people's worktrees with it. Reset a clone with git clean -ffdx, and remove a worktree with git worktree remove.
The lab#
The lab lives in tina4-documentation/lab/. It's one Docker Compose project, tina4-lab, with every service the four suites need, and the images are copied from the repos' CI workflows. Its containers, volumes and network are all named tina4-lab-*.
Start, check, use, stop#
Run these from the tina4-documentation checkout, in Git Bash (in PowerShell, bash is usually WSL's bash, not Git's):
bash lab/up # start everything; waits until every service is healthybash lab/up postgres redis # or just somebash lab/check # runtime checks (memcached's clock); repairs and logsdocker compose -f lab/compose.yaml psbash lab/down # stop; data volumes keptbash lab/down --volumes # stop and wipe the data and certificateslab/up won't hand you a half-ready lab. Every healthcheck creates the per-framework databases, initiates the Mongo replica set or imports the Keycloak realm before it reports healthy, and lab/up exits 1 naming any service that never got there. The first run builds MinIO from source and pulls about 25 images.
Source the env in the shell that will run the suite, and only there:
# Git Bash or WSL. ../tina4-documentation/lab/lab-env.sh python # or php | ruby | nodejs# PowerShell: allow the unsigned script for this process onlypowershell -ExecutionPolicy Bypass. ..\tina4-documentation\lab\lab-env.ps1 pythonThe env file exports the canonical TINA4_TEST_* names (ADR-0038) and nothing else, plus TINA4_REQUIRE_SERVICES=1, TINA4_REQUIRE_OIDC=1 and TINA4_NO_BROWSER=true. With no framework argument you get CI's database names, shared by everyone. For CI's second Mongo pass against the MongoDB 8 replica set, set TINA4_LAB_MONGO_RS=1 before you source it.
Ports#
Every port is bound to 127.0.0.1 only, in one block, so the lab never fights another project for 5432, 6379 or 27017.
| Ports | Services |
|---|---|
| 24101-24105 | PostgreSQL, PostGIS, MySQL, MSSQL, Firebird |
| 24106-24109 | Redis, Redis with a password, Valkey, the shared memcached |
| 24110-24111 | MongoDB 7, MongoDB 8 replica set rs0 |
| 24112-24115 | RabbitMQ (and its management port), Kafka, MinIO |
| 24116-24121 | GreenMail, Mosquitto (anonymous, password, TLS), EMQX |
| 24122-24126 | Neo4j, Memgraph, ArangoDB, Keycloak, NATS |
| 24127-24130 | memcached for python, php, ruby, nodejs |
| 4025 4465 4143 4993 4587 4825 4144 | The Transport Layer Security (TLS) mail servers, on the ports the suites fix |
compose.yaml has the credentials, and each env file has every name it sets. A test that dials a default port instead of reading its TINA4_TEST_* name will fail here. That's a test bug, so fix the read.
Four suites at once#
Pass your framework when you source the env, and four suites can run side by side without dropping each other's tables or flushing each other's cache:
| none (CI) | python | php | ruby | nodejs | |
|---|---|---|---|---|---|
| PostgreSQL database | tina4_py | tina4_py | tina4_php | tina4_rb | tina4_node |
| MySQL and MSSQL database | tina4_test | tina4_test_py | tina4_test_php | tina4_test_rb | tina4_test_node |
| Firebird file | test.fdb | tina4_py.fdb | tina4_php.fdb | tina4_rb.fdb | tina4_node.fdb |
| Redis and Valkey index | 0 | 1 | 2 | 3 | 4 |
| Redis-with-password index | 3 | 11 | 12 | 13 | 14 |
| memcached port | 24109 | 24127 | 24128 | 24129 | 24130 |
All four frameworks' caches share the key prefix tina4:cache:, and clear() deletes everything under it, so two suites on one Redis database wipe each other. memcached has no namespaces at all, which is why each framework gets its own server. TINA4_TEST_REDIS_HOST and _PORT carry no index, so read the _URL.
HOME isolation#
Sourcing the env points HOME and USERPROFILE at a throwaway directory: TINA4_TEST_HOME if you set it first, otherwise a fresh temp directory. One suite run rewrote 38 files in a developer's real ~/.claude/skills before this existed.
export TINA4_TEST_HOME="$PWD/.tmp-home" # a folder in your own worktree. ../tina4-documentation/lab/lab-env.sh phpThe real values wait in TINA4_LAB_REAL_HOME and TINA4_LAB_REAL_USERPROFILE. That shell has lost ~/.gitconfig and ~/.ssh, so commit and push from another one. TINA4_LAB_ISOLATE_APPDATA=1 moves APPDATA and LOCALAPPDATA as well. It's off by default, because uv, composer and npm keep their caches there.
Other projects' containers#
The lab's names, network and ports are its own, and it touches nothing else. Do the same. Never stop, restart, remove or reconfigure a container, volume or network that isn't tina4-lab-*. If another project holds a port a test wants, the test is reading a default it shouldn't.
Gotchas found the hard way#
Files, paths and the shell#
| Gotcha | Symptom | Fix |
|---|---|---|
| Line endings | A one-line edit shows as a whole-file change in git diff --stat. Python's text-mode write (write_text, open(..., "w")) turns LF into CRLF on Windows, and so does Ruby's File.write. | Write bytes, or pass newline='' in Python and use File.binwrite in Ruby. Run git diff --stat before every commit. |
| Tests that write your real home or install globally | The skills-install tests rewrote the real ~/.claude/skills. The AI installer tests ran pip install --upgrade tina4-ai against the first pip on PATH. | Isolate HOME and USERPROFILE (the env file does it). Set PIP_TARGET to a throwaway folder too. Windows reads USERPROFILE, not HOME, so a test that only moves HOME still writes the real one. |
| Symlinks | EACCES or EPERM from symlink(); cases skip with [needs:symlink-privilege]. | Turn on Developer Mode (Settings, System, For developers). Without it an unprivileged user can't create a symlink. |
.cmd shims and cmd.exe | npm, npx, composer and the tina4 client are .cmd or .bat files. Windows runs them through cmd.exe, which re-parses the whole command line, so an argument with spaces or & splits into two, and a timeout kills cmd.exe but leaves its children holding the folder. | Start the real executable (node plus the tool's script) with an argument list. Where a batch file is unavoidable, escape each argument for cmd.exe. A tool lookup must try every PATHEXT extension, not just .exe. |
/dev/null, exec, cd in shell strings | A POSIX shell string fails under cmd.exe, and a cd to another drive doesn't change drive. | Spawn with an argument list. Use the platform's null device. |
| PowerShell execution policy | lab-env.ps1 is not digitally signed. | powershell -ExecutionPolicy Bypass, or Set-ExecutionPolicy -Scope Process Bypass. Both last for that process only; never change the machine's policy. |
bash in PowerShell | bash lab/up runs inside WSL, not Git Bash. | Run lab scripts from Git Bash, or call Git's bash.exe by its full path. |
| The codeql CLI | tina4 codeql fails: the codeql command-line tool isn't installed by default. | Install it if you're allowed to. If not, push without the local check, say so in the pull request, and confirm the pull request's code scanning shows 0 new alerts. |
Processes, pipes and ports#
| Gotcha | Symptom | Fix |
|---|---|---|
| Windows pipes can't be non-blocking | The PHP suite hung at about 50%: a test read php -S stderr from a pipe after stream_set_blocking(false), which Windows ignores, so the read waited for a server that never exits. | Send a child's stderr to a file, not a pipe you poll. |
SO_REUSEADDR shares a port | A second server binds on top of a listening one and both "work". A specific address also binds beside a wildcard listener. | Bind exclusively (SO_EXCLUSIVEADDRUSE on Windows; PHP's Tina4\PortBind does this). Probe a port on the host the server will bind, by binding without listening. |
netstat port matching | Port 5123 looked "held" by a listener on 51230, or by a connection whose far end was 5123. | Parse the local address and compare its port exactly. Never substring-match :5123. |
localhost resolves to ::1 first | Every Kafka reconnect took about 2s: the broker advertised localhost, the client tried IPv6, waited for the refusal, then fell back. Deadline tests failed. | The lab advertises 127.0.0.1. In your own code and tests, use 127.0.0.1 for anything on the lab. |
| Node: the libuv abort at exit | Assertion failed: !(handle->flags & UV_HANDLE_CLOSING), src\win\async.c, exit 127 or 0xC0000409, after a process used fetch(). process.exit() raced V8 compiling undici's WebAssembly parser. | Exit once the event loop drains: exitOnceDrained() from packages/core/src/server.ts. Every test file ends with it, never process.exit(). |
Node 25 rmSync | Removing a temp folder right after killing a child fails with EPERM. | Retry until the child's handles close (test/_tempDir.ts). |
Services and drivers#
| Gotcha | Symptom | Fix |
|---|---|---|
| Firebird: ext-interbase's hidden default link | The suite hung in DROP TABLE behind an attachment that should have closed. ext-interbase keeps the last-opened link as its default, so ibase_close($link) only dropped one reference. | Release the shared link on the final close (FirebirdAdapter::releaseSharedLink()). Check MON$ATTACHMENTS when a Firebird test hangs. |
| The WSL2 virtual machine's wall clock steps | Timing assertions fail at random: MySQL's SLEEP(2) returned in 0.65-1.4s, and an interval measured against a service comes out shorter than the wait that produced it. The Docker Desktop VM runs its clock slow, then steps it back into line. | Don't assert tight wall-clock bounds against a service in the VM. Make the test wait on something it controls (hold a row lock for 2s instead of SLEEP(2)), leave headroom in a bound, and re-run a lone timing failure before you chase it. |
| memcached's clock drifts | The over-30-day time to live (TTL) tests fail. memcached counts from its start time with a monotonic clock that runs slow in the Docker Desktop virtual machine, so its "now" falls behind the host. | bash lab/check restarts the shared memcached past 2s of skew and logs it. The TTL tests measure the drift themselves and tag [needs:memcached-clock-in-sync] when it's out. |
| MSSQL with ODBC Driver 18 | The connection fails on certificate verification: Driver 18 verifies by default, and the lab's SQL Server certificate is self-signed. | The lab URL carries ?trustServerCertificate=true, a lab-only opt-in (ADR-0113). Never import a certificate authority into the machine's stores. |
| ODBC driver missing | Live Open Database Connectivity (ODBC) cases skip with [needs:odbc-driver]. | Install the psqlODBC x64 driver (PostgreSQL Unicode(x64)) on the host. |
| PHP: ext-mongodb too old | composer install refuses: mongodb/mongodb wants ext-mongodb ^2.4. | Download the official php_mongodb build that matches your PHP (8.4, thread-safe, x64), check its SHA256, and load it through PHP_INI_SCAN_DIR, with no edit to php.ini (below). |
| Ruby: native gems | bundle install aborts on rdkafka (librdkafka won't build on Windows); mysql2 needs a MySQL client library RubyInstaller doesn't ship. | rdkafka is in the :kafka group and mysql2 in its own :mysql group. Leave out kafka; the Kafka specs tag [needs:posix-rdkafka]. |
| Ruby: client libraries | mysql2 or fb won't build or load. | Keep the client libraries in a local folder, not on the system: libmariadb.dll and include/mysql from the MariaDB server zip, fbclient.dll and include from the Firebird x64 zip. Point bundler's build flags at them and load them through RUBY_DLL_PATH (below). |
Loading ext-mongodb without touching php.ini#
D=C:/tina4-clients/php-mongodb # ext/php_mongodb.dll is the downloaded buildmkdir -p "$D/conf.d"echo "extension=\"$D/ext/php_mongodb.dll\"" > "$D/conf.d/50-mongodb.ini"export PHP_INI_SCAN_DIR="$D/conf.d"php -m | grep -i mongodbcomposer installThe Windows builds are on the mongo-php-driver GitHub releases page. Pick the one named for your PHP minor version, ts and x64. The variable lasts as long as the shell, and the child PHP processes the suite starts inherit it.
Ruby's client libraries#
C=C:/tina4-clients # anywhere you like; nothing is installed system-widebundle config set --local build.mysql2 "--with-mysql-include=$C/mariadb/include/mysql --with-mysql-lib=$C/mariadb/lib"bundle config set --local build.fb "--with-firebird-include=$C/firebird/include --with-firebird-lib=$C/firebird"export RUBY_DLL_PATH="$C/mariadb/lib;$C/firebird" # RubyInstaller's DLL search pathexport MARIADB_PLUGIN_DIR="$C/mariadb/lib/plugin" # MySQL 8's authentication pluginbundle installWorking alongside others on a shared box#
Several people, or several agents, may be running suites on the same machine at once. These rules keep you from breaking their runs, and them from breaking yours.
Kill only your own processes, by PID or by your worktree path. Never kill by name or pattern: a pattern kill took out six other people's runs at once. Find yours by path:
powershellGet-CimInstance Win32_Process | Where-Object { $_.CommandLine -like '*\my-worktree\*' } | Select-Object ProcessId, Name, CommandLineStop-Process -Id <pid>To end a whole process tree, run
taskkill /PID <pid> /T /F(in Git Bash, writetaskkill //PID <pid> //T //F, or MSYS turns/Tinto a path).- Use your own ports. Before you pick one, check nobody is listening on it:
Get-NetTCPConnection -LocalPort <port> -State Listen. Don't use the lab's block. - No
git stash. The stash list is shared by every worktree of a repository, so you can pop someone else's work. Commit to your branch instead, or start another worktree. TINA4_NO_BROWSER=truefor every local run, so no test opens a browser tab on somebody's screen. The env file sets it.TINA4_REQUIRE_SERVICES=1before you call anything green. Under it, a test that skips for a service the lab provides fails the run instead of passing quietly. Read the runner's summary line: zero failures and zero un-excused skips. A skipped test is unverified, not passed. The env file sets this as well.- Leave the lab running. Others depend on it. Don't run
lab/downor restart atina4-lab-*container while anyone else is mid-run; ask first.
Contributing has the rules every pull request follows, and Releasing Tina4 picks up once the suites are green.