Skip to content

Task is run in the wrong subdirectory #2207

@chimbori

Description

@chimbori

Description

When I set dir: '{{.USER_WORKING_DIR}}', my tasks are run inside a subdirectory in the current directory, instead of within the directory my shell is in.

———————————————————————————————————————————————————————————————[ 04:33:04 ]———— /…/Bug Reports/Taskfile Backslash Space $ tree . . ├── sub-directory │   └── sub-sub-directory with spaces └── Taskfile.yml 3 directories, 1 file ———————————————————————————————————————————————————————————————[ 04:33:06 ]———— /…/Bug Reports/Taskfile Backslash Space $ cat Taskfile.yml version: '3' tasks: tree-parent: desc: tree dir: '{{.USER_WORKING_DIR}}' cmds: - echo "{{.USER_WORKING_DIR}}" - tree . ———————————————————————————————————————————————————————————————[ 04:33:09 ]———— /…/Bug Reports/Taskfile Backslash Space $ tree . . ├── sub-directory │   └── sub-sub-directory with spaces └── Taskfile.yml 3 directories, 1 file ———————————————————————————————————————————————————————————————[ 04:33:13 ]———— /…/Bug Reports/Taskfile Backslash Space $ t tree-parent task: [tree-parent] echo "/…/Bug Reports/Taskfile Backslash Space" /…/Bug Reports/Taskfile Backslash Space task: [tree-parent] tree . . └── subdirectory\ with\ spaces 2 directories, 0 files ———————————————————————————————————————————————————————————————[ 04:33:20 ]———— /…/Bug Reports/Taskfile Backslash Space $ 

Expected

  • When I run t tree-parent (t is an alias for task), I expect it to show the same output as running tree . directly in the same directory.

Actual

  • Even though task reports the {{.USER_WORKING_DIR}} correctly, it runs the task in sub-directory instead.

Without dir: '{{.USER_WORKING_DIR}}', this works as expected.


I’m also seeing some other wonkiness where task is in fact creating brand new subdirectories on disk. If sub directory with spaces exists on disk, Task creates sub\ directory\ with\ spaces alongside it — the backslashes are present in the actual filename, not escape characters, on macOS. I’m trying to prepare a minimal repro case for it, but ran into this current issue in the process of doing that.

Version

3.43.2

Operating system

macOS

Experiments Enabled

No response

Example Taskfile

version: '3' tasks: tree-parent: desc: tree dir: '{{.USER_WORKING_DIR}}' cmds: - echo "{{.USER_WORKING_DIR}}" - tree .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions