Tina4

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 WindowsWSL Ubuntu
What it provesThe framework works on WindowsThe suite passes the way continuous integration (CI) runs it
StatusBest effort: some cases skip with a [needs:...] tagRecommended for a full run before you call a change green
POSIX-only tests (fork, signals, symlinks, file modes, PTY)Skipped and taggedRun
ServicesThe lab, on 127.0.0.1The 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:

FrameworkToolchain that worked
PythonPython 3.14 with uv
PHPPHP 8.4, the Zend Thread Safety (ZTS) x64 build
RubyRuby 3.3.10 from RubyInstaller (x64-mingw-ucrt), with its MSYS2 devkit
NodeNode 25

Start the lab and source its env first (see The lab). Then, in the framework checkout:

bash
# 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 typecheck

Always 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:

FrameworkLast native run with the lab
Python10804 passed, 0 failed, 126 skipped (every skip tagged), 43m
PHP7518 tests, 0 failures, 131 skipped, 44m; 27 graph cases wait on a driver decision
Rubynot green yet: host prerequisites (Developer Mode, the client libraries)
Node24213 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.

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:

bash
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-dev

PHP 8.4 from the ondrej Personal Package Archive (PPA):

bash
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.4

php8.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:

bash
# 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 bundler

Python with uv, from Astral's installer:

bash
curl -LsSf https://astral.sh/uv/install.sh | sh

Node: 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.

bash
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 test

If 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:

bash
# 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
powershell
# from Windowspowershell -ExecutionPolicy Bypass -File lab\wsl-test.ps1 nodejs v3

ref 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 PATH and never installs anything system-level;
  • keeps a WSL-native clone per repo in ~/tina4-test/<repo>, checks out the ref detached and resets it with git clean, keeping .venv, vendor, node_modules and .bundle;
  • fetches CI's pinned native tina4 CLI (the Rust client), checks it against the release's SHA256SUMS, keeps it in ~/tina4-test/bin and puts it first on PATH. The ~/.local/bin/tina4 you 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
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 certificates

lab/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:

bash
# Git Bash or WSL. ../tina4-documentation/lab/lab-env.sh python     # or php | ruby | nodejs
powershell
# PowerShell: allow the unsigned script for this process onlypowershell -ExecutionPolicy Bypass. ..\tina4-documentation\lab\lab-env.ps1 python

The 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.

PortsServices
24101-24105PostgreSQL, PostGIS, MySQL, MSSQL, Firebird
24106-24109Redis, Redis with a password, Valkey, the shared memcached
24110-24111MongoDB 7, MongoDB 8 replica set rs0
24112-24115RabbitMQ (and its management port), Kafka, MinIO
24116-24121GreenMail, Mosquitto (anonymous, password, TLS), EMQX
24122-24126Neo4j, Memgraph, ArangoDB, Keycloak, NATS
24127-24130memcached for python, php, ruby, nodejs
4025 4465 4143 4993 4587 4825 4144The 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)pythonphprubynodejs
PostgreSQL databasetina4_pytina4_pytina4_phptina4_rbtina4_node
MySQL and MSSQL databasetina4_testtina4_test_pytina4_test_phptina4_test_rbtina4_test_node
Firebird filetest.fdbtina4_py.fdbtina4_php.fdbtina4_rb.fdbtina4_node.fdb
Redis and Valkey index01234
Redis-with-password index311121314
memcached port2410924127241282412924130

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.

bash
export TINA4_TEST_HOME="$PWD/.tmp-home"      # a folder in your own worktree. ../tina4-documentation/lab/lab-env.sh php

The 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#

GotchaSymptomFix
Line endingsA 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 globallyThe 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.
SymlinksEACCES 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.exenpm, 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 stringsA 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 policylab-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 PowerShellbash 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 CLItina4 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#

GotchaSymptomFix
Windows pipes can't be non-blockingThe 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 portA 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 matchingPort 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 firstEvery 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 exitAssertion 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 rmSyncRemoving a temp folder right after killing a child fails with EPERM.Retry until the child's handles close (test/_tempDir.ts).

Services and drivers#

GotchaSymptomFix
Firebird: ext-interbase's hidden default linkThe 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 stepsTiming 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 driftsThe 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 18The 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 missingLive 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 oldcomposer 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 gemsbundle 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 librariesmysql2 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#

bash
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 install

The 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#

bash
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 install

Working 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:

    powershell
    Get-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, write taskkill //PID <pid> //T //F, or MSYS turns /T into 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=true for every local run, so no test opens a browser tab on somebody's screen. The env file sets it.
  • TINA4_REQUIRE_SERVICES=1 before 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/down or restart a tina4-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.