Skip to content

Task creates empty directories with backslashes when paths contain spaces #2226

@daeh

Description

@daeh

Description

When running Task with a file path containing spaces, empty directories with backslash-escaped spaces are being created unexpectedly.

Details

I have a Taskfile at the path: ~/Desktop/untitled folder test/demo-project/Taskfile.yml
This Taskfile includes another taskfile in the same directory: ~/Desktop/untitled folder test/demo-project/TasksPython.yml

When I run task python:demo from ~/Desktop/untitled folder test/demo-project, Task makes empty directories:

~/Desktop/untitled\ folder\ test
~/Desktop/untitled\ folder\ test/demo-project

The task command itself executes successfully:

❯ task python:demo
task: [python:demo] echo "test"
test

The files are:

# Taskfile.yml
version: "3"

includes:
  python:
    taskfile: "TasksPython.yml"
    flatten: false
# TasksPython.yml
version: "3"

tasks:
  demo:
    - echo "test"

Additional information

  • This issue only occurs when using the includes directive in the main Taskfile
  • The empty directories are created regardless of whether the flatten option is set to true or false (i.e. the behavior is the same running task demo with flatten: true)
  • The issue appears to be related to how Task handles paths with spaces

Task: 3.43.3
MacOS: 14.7.5
Shell: zsh 5.9 (x86_64-apple-darwin23.0)

❯ task --experiments
* GENTLE_FORCE:     off
* REMOTE_TASKFILES: off
* ENV_PRECEDENCE:   off

Version

3.43.3

Operating system

MacOS 14.7.5

Experiments Enabled

No response

Example Taskfile

version: "3"

includes:
  python:
    taskfile: "TasksPython.yml"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions