Skip to content

task installed via npm always returns 0 exit code when build failed #2530

@madconst

Description

@madconst

Description

  1. What I did: run task to build project. The project build failed (compilation error). Task printed 'Failed to run task "backend": exit status 2` in red.
  2. What I expected: exit code ($? in bash) is non-zero.
  3. What I got: exit code is 0.

The problem caused CI to not stop the build and erroneously continue with tests.

I have found that it is task installed via npm that always returns 0 exit code. It's easy to reproduce that, just add any command to the target that returns non-zero extit code. Then:

$ task
Failed to run task "backend": exit status 2
$ echo $?
0

If installing task via apt install, the exit code is correct (201).

Minimal working example:

version: '3'

tasks:
  default:
    cmds:
      - false

How to reproduce:

$ npm install -g @go-task/cli
$ ~/.nvm/versions/node/v24.10.0/bin/task # full path to ensure task from npm is used
$ echo $?
0
$ /usr/bin/task
$ echo $?
201

Version

3.45.5

Operating system

Linux (Ubuntu)

Experiments Enabled

No response

Example Taskfile

version: '3'

tasks:
  default:
    cmds:
      - false

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: releasingChanges related to the release process.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions