-
Notifications
You must be signed in to change notification settings - Fork 187
Open
Description
Environment
- tailwindcss-rails: 4.4.0
- tailwindcss-ruby: 4.1.16
- Ruby: 3.4.2
- Rails: 8.1.1
- Docker: Debian-based container
- Watchman: v2024.11.04.00 (installed and working)
- Process manager: Foreman via Procfile.dev
Problem
bin/rails tailwindcss:watch exits immediately after initial build with exit code 0, instead of staying in watch mode.
Procfile.dev
web: bin/rails server
css: bin/rails tailwindcss:watch
Output
14:37:19 css.1 | ≈ tailwindcss v4.1.16
14:37:20 css.1 | Done in 314ms
14:37:20 css.1 | exited with code 0
14:37:20 system | sending SIGTERM to all processes
The CSS process exits immediately after "Done", which triggers foreman to send SIGTERM to all other processes.
Investigation
1. Watchman is installed and working
$ watchman version
version: 20251222.073500.0
buildinfo: v2024.11.04.00
$ watchman watch-list
{
"version": "20251222.073500.0",
"roots": [
"/app"
]
}2. Bug in watch_command method
In lib/tasks/build.rake:
def watch_command(always: false, **kwargs)
compile_command(**kwargs).tap do |command|
command << "-w"
command << "always" if always # This produces: -w always (two separate args)
end
endThis generates -w always as two separate arguments, but the tailwindcss CLI expects --watch=always or --watch always as a single flag with value.
3. Even with correct flag, tailwindcss exits
Tried running directly:
$ bundle exec tailwindcss --input app/assets/stylesheets/application.css --output app/assets/builds/application.css --watch=always
≈ tailwindcss v4.1.16
Done in 455ms
$ # Process exits immediatelyExpected Behavior
The tailwindcss:watch task should stay running and rebuild CSS when source files change.
Workaround Attempted
- Passing
alwaysargument:css: bin/rails tailwindcss:watch[always]- doesn't work - Direct tailwindcss command with
--watch=always- exits immediately - FIFO stdin wrapper to keep stdin open - exits immediately
Possible Causes
- The
watch_commandmethod incorrectly constructs the watch flag - Tailwindcss v4 may have different stdin/tty requirements for watch mode
- In Docker/non-interactive environment, tailwindcss may need additional flags
Suggested Fix
At minimum, fix the watch_command to properly pass the flag:
def watch_command(always: false, **kwargs)
compile_command(**kwargs).tap do |command|
command << (always ? "--watch=always" : "--watch")
end
endBut there may be a deeper issue with tailwindcss v4 watch mode in non-interactive environments.
Metadata
Metadata
Assignees
Labels
No labels