Skip to content

Task creates spurious brand new directories on disk with backslashes preceding every space #2208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chimbori opened this issue Apr 25, 2025 · 5 comments · Fixed by #2216
Closed
Labels
area: variables Changes related to variables.

Comments

@chimbori
Copy link

Description

I have a Taskfile in a parent directory, and another Taskfile in a subdirectory of the parent, using the includes syntax.

The file names / directory names contain space characters (on macOS).

When running a task from the from the sub-directory Taskfile, Task ends up creating brand new spurious directories on disk.

Looks like it’s reading the full path, escaping it incorrectly, and then passing it on to os.MkdirAll.

This has the side-effect that Task can no longer find binaries in my chosen directory (./my-binary under USER_WORKING_DIR), because now it’s searching the wrongly-created path instead.

———————————————————————————————————————————————————————————————[ 05:07:55 ]————
/…/BugReports/Taskfile $ tree .
.
└── sub directory with spaces
    ├── sub-sub-directory with spaces
    │   └── Taskfile.yml
    └── Taskfile.yml

3 directories, 2 files
———————————————————————————————————————————————————————————————[ 05:07:57 ]————
/…/BugReports/Taskfile $ cat "sub directory with spaces/Taskfile.yml"
version: '3'

tasks:
  tree-parent:
    desc: tree
    # dir: '{{.USER_WORKING_DIR}}'
    cmds:
      - echo "{{.USER_WORKING_DIR}}"
      - tree .
———————————————————————————————————————————————————————————————[ 05:08:08 ]————
/…/BugReports/Taskfile $ cat "sub directory with spaces/sub-sub-directory with spaces/Taskfile.yml"
version: '3'

includes:
  parents:
    taskfile: ..
    flatten: true

tasks:
  tree-subdir:
    desc: tree
    cmds:
      - tree .
———————————————————————————————————————————————————————————————[ 05:08:16 ]————
/…/BugReports/Taskfile $ cd "sub directory with spaces/sub-sub-directory with spaces"
———————————————————————————————————————————————————————————————[ 05:08:32 ]————
/…/BugReports/Taskfile/sub directory with spaces/sub-sub-directory with spaces $ t tree-parent
task: [tree-parent] echo "/…/BugReports/Taskfile/sub directory with spaces/sub-sub-directory with spaces"
/…/BugReports/Taskfile/sub directory with spaces/sub-sub-directory with spaces
task: [tree-parent] tree .
.

0 directories, 0 files
———————————————————————————————————————————————————————————————[ 05:08:36 ]————
/…/BugReports/Taskfile/sub directory with spaces/sub-sub-directory with spaces $ cd ../../
———————————————————————————————————————————————————————————————[ 05:08:39 ]————
/…/BugReports/Taskfile $ tree .
.
├── sub directory with spaces
│   ├── sub-sub-directory with spaces
│   │   └── Taskfile.yml
│   └── Taskfile.yml
└── sub\ directory\ with\ spaces
    └── sub-sub-directory\ with\ spaces

5 directories, 2 files
———————————————————————————————————————————————————————————————[ 05:08:41 ]————

Version

3.43.2

Operating system

macOS

Experiments Enabled

No response

Example Taskfile

version: '3'

includes:
  parents:
    taskfile: ..
    flatten: true

tasks:
  tree-subdir:
    desc: tree
    cmds:
      - tree .
@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Apr 25, 2025
@chimbori
Copy link
Author

Confirmed that this is a regression in v3.43; unable to repro with v3.42.1

Thanks!

@pd93 pd93 added area: variables Changes related to variables. and removed state: needs triage Waiting to be triaged by a maintainer. labels Apr 27, 2025
@pd93
Copy link
Member

pd93 commented Apr 27, 2025

This was caused by #2186 which has been reverted in 68d5095 and released in v3.43.3.

@chimbori
Copy link
Author

Thanks for the quick response, but the issue has not been resolved with 3.43.3.

———————————————————————————————————————————————————————————————[ 07:19:12 ]————
/…/BugReports/Taskfile $ tree .
.
└── sub directory with spaces
    ├── sub-sub-directory with spaces
    │   └── Taskfile.yml
    └── Taskfile.yml

3 directories, 2 files
———————————————————————————————————————————————————————————————[ 07:19:22 ]————
/…/BugReports/Taskfile $ cat sub\ directory\ with\ spaces/Taskfile.yml
version: '3'

tasks:
  tree-parent:
    desc: tree
    # dir: '{{.USER_WORKING_DIR}}'
    cmds:
      - echo "{{.USER_WORKING_DIR}}"
      - tree .
———————————————————————————————————————————————————————————————[ 07:19:34 ]————
/…/BugReports/Taskfile $ cat sub\ directory\ with\ spaces/sub-sub-directory\ with\ spaces/Taskfile.yml
version: '3'

includes:
  parents:
    taskfile: ..
    flatten: true

tasks:
  tree-subdir:
    desc: tree
    cmds:
      - tree .
———————————————————————————————————————————————————————————————[ 07:19:53 ]————
/…/BugReports/Taskfile $ cd sub\ directory\ with\ spaces/sub-sub-directory\ with\ spaces/
———————————————————————————————————————————————————————————————[ 07:20:03 ]————
/…/BugReports/Taskfile/sub directory with spaces/sub-sub-directory with spaces $ task tree-parent
task: [tree-parent] echo "/…/BugReports/Taskfile/sub directory with spaces/sub-sub-directory with spaces"
/…/BugReports/Taskfile/sub directory with spaces/sub-sub-directory with spaces
task: [tree-parent] tree .
.

0 directories, 0 files
———————————————————————————————————————————————————————————————[ 07:20:10 ]————
/…/BugReports/Taskfile/sub directory with spaces/sub-sub-directory with spaces $ cd ../../
———————————————————————————————————————————————————————————————[ 07:20:20 ]————
/…/BugReports/Taskfile $ tree .
.
├── sub directory with spaces
│   ├── sub-sub-directory with spaces
│   │   └── Taskfile.yml
│   └── Taskfile.yml
└── sub\ directory\ with\ spaces
    └── sub-sub-directory\ with\ spaces

5 directories, 2 files
———————————————————————————————————————————————————————————————[ 07:20:23 ]————
/…/BugReports/Taskfile $ task --version
3.43.3
———————————————————————————————————————————————————————————————[ 07:20:28 ]————

@pd93
Copy link
Member

pd93 commented Apr 28, 2025

@chimbori Apologies, I misunderstood the problem. Reopening for now, but hopefully #2216 will fix for you.

@pd93 pd93 reopened this Apr 28, 2025
@chimbori
Copy link
Author

Thank you again!

It no longer creates double-escaped subdirectories in 3.43.3+fc17343.

It still runs commands in the wrong directory, but that might be a separate bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: variables Changes related to variables.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants