T
Task2w ago
Nintron

Dependency hangs on rebuild

I have configured in my Taskfile a few tasks, one for building tailwind styles, one for building SQLC code, and then one that builds my Go program but has the other 2 tasks as dependencies. I want to create a parent task to run this build output binary, and rebuild it whenever any file changes, currently that has left me with this Taskfile:
version: '3'

interval: 100ms

env:
STATIC_DIR: "web/static"

dotenv: [".env"]

tasks:
live:
desc: Run live dev environment.
deps: [build:go:app]
watch: true
cmds:
- bin/app

build:go:app:
deps: [build:go:sqlc, build:styles]
env:
GOARCH: amd64
GOOS: linux
CGO_ENABLED: 0
cmds:
- "go build -o bin/app cmd/app/main.go"
sources:
- "**/*.go"
- "**/*.html.tmpl"
generates:
- bin/app

build:go:sqlc:
cmds:
- sqlc generate
sources:
- "sqlc.yaml"
- "database/queries/**/*.sql"
- "database/migrations/**/*.sql"
generates:
- "database/gensql/**/*"

build:styles:
cmds:
- "tailwindcss -i web/styles/tw-input.css -o {{.STATIC_DIR}}/tw-output.css --minify"
sources:
- "web/**/*.{html.tmpl,go}"
- web/styles/tw-input.css
generates:
- web/static/tw-output.css
version: '3'

interval: 100ms

env:
STATIC_DIR: "web/static"

dotenv: [".env"]

tasks:
live:
desc: Run live dev environment.
deps: [build:go:app]
watch: true
cmds:
- bin/app

build:go:app:
deps: [build:go:sqlc, build:styles]
env:
GOARCH: amd64
GOOS: linux
CGO_ENABLED: 0
cmds:
- "go build -o bin/app cmd/app/main.go"
sources:
- "**/*.go"
- "**/*.html.tmpl"
generates:
- bin/app

build:go:sqlc:
cmds:
- sqlc generate
sources:
- "sqlc.yaml"
- "database/queries/**/*.sql"
- "database/migrations/**/*.sql"
generates:
- "database/gensql/**/*"

build:styles:
cmds:
- "tailwindcss -i web/styles/tw-input.css -o {{.STATIC_DIR}}/tw-output.css --minify"
sources:
- "web/**/*.{html.tmpl,go}"
- web/styles/tw-input.css
generates:
- web/static/tw-output.css
There is two problems I have with this though... - The first is super minor and I'm not bothered much by it, but that's that on first run of task live Taskfile will see all the deps are up to date, run the cmd bin/app and then instantly kill it. This isn't too bad, as on second run Taskfile doesn't just kill the command so all is great, however, the second problem is a roadblock. - The second problem is that if I make any changes that would cause build:go:app to rerun, it hangs forever on the cmd go build -o bin/app cmd/app/main.go. Now, if I run that task directly it's fine, no hang, but if Taskfile reruns that task due to a file change causing the re-eval then it hangs forever. My terminal logs look like this when I make a change:
task: Task "build:go:sqlc" is up to date
task: [build:styles] tailwindcss -i web/styles/tw-input.css -o web/static/tw-output.css --minify
≈ tailwindcss v4.1.7

Done in 62ms
task: [build:go:app] go build -o bin/app cmd/app/main.go
task: Task "build:go:sqlc" is up to date
task: [build:styles] tailwindcss -i web/styles/tw-input.css -o web/static/tw-output.css --minify
≈ tailwindcss v4.1.7

Done in 62ms
task: [build:go:app] go build -o bin/app cmd/app/main.go
and it just hangs forever on task: [build:go:app] go build -o bin/app cmd/app/main.go. If any more info is needed to debug just let me know, or if there is some better way to go this whole thing.
2 Replies
Nintron
NintronOP2w ago
One update, I think the first issue is just this bug reported here: https://github.com/go-task/task/issues/2202
GitHub
Watch sends interrupt signal right away in v3.43.x · Issue #2202 ...
Description Upgrading from v3.42.1 to v3.43.x (both .1 and .2) breaks the --watch functionality. Using an older version, for example, v3.42.1, works as it should: ❯ task --version Task version: v3....
Nintron
NintronOP2w ago
I haven't found a solution yet, but a decent work around is to just save the file twice. When I save it the first time it just hangs forever on the build:go:app task, but saving again causes it to no longer hang and it rebuilds successfully.

Did you find this page helpful?