Skip to content

fix(remote): define special variables behavior#2847

Merged
pd93 merged 3 commits into
mainfrom
fix/special-variables-remote-taskfiles
Jun 29, 2026
Merged

fix(remote): define special variables behavior#2847
pd93 merged 3 commits into
mainfrom
fix/special-variables-remote-taskfiles

Conversation

@vmaerten

@vmaerten vmaerten commented May 17, 2026

Copy link
Copy Markdown
Member

Summary

Closes #2267.
Defines the semantics of file-path special variables when a Taskfile is loaded from a remote source (HTTP/HTTPS/Git):

Variable Local Remote
TASKFILE / ROOT_TASKFILE absolute path raw URL (unchanged)
TASKFILE_DIR / ROOT_DIR filepath.Dir(...) "" (a DIR cannot point to a URL)
TASK_DIR SmartJoin(c.Dir, task.dir) resolved against USER_WORKING_DIR

This fixes the broken outputs reported in the issue (ROOT_TASKFILE: https:/taskfile.dev with one slash missing, TASKFILE_DIR: https:, empty ROOT_DIR/TASK_DIR) by no longer applying filepath.Dir / filepath.Join to URLs.

taskfile.isRemoteEntrypoint is exported as IsRemoteEntrypoint so the compiler can dispatch on the actual nature of the entrypoint instead of relying on the side-effect c.Dir == "".

The TASK_DIR rules in remote mode are:

  • task.dir empty : USER_WORKING_DIR
  • task.dir absolute : kept as-is
  • task.dir relative : SmartJoin(USER_WORKING_DIR, dir)

vmaerten added 3 commits May 17, 2026 17:59
Issue #2267 — Define semantics of file-path special variables when the
Taskfile is loaded from a remote source (HTTP/HTTPS/Git):

- TASKFILE / ROOT_TASKFILE: raw URL (fixes the broken `https:/...`
  caused by filepath.Join collapsing the double slash)
- TASKFILE_DIR / ROOT_DIR: empty string — a DIR variable cannot point
  to a URL
- TASK_DIR: resolved against USER_WORKING_DIR

Export taskfile.IsRemoteEntrypoint so the compiler can dispatch on the
nature of the entrypoint without relying on `c.Dir == ""` (a side
effect of the remote path).
The behavior is already documented in experiments/remote-taskfiles.md
and validated by the table-driven test.
Build paths from t.TempDir() so they are valid absolute paths on
Windows too (filepath.IsAbs treats `/abs/path` as non-absolute there).
@vmaerten
vmaerten marked this pull request as ready for review May 18, 2026 16:53

@pd93 pd93 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one! Thanks @vmaerten

@pd93
pd93 merged commit 9910c33 into main Jun 29, 2026
19 checks passed
@pd93
pd93 deleted the fix/special-variables-remote-taskfiles branch June 29, 2026 18:25
pd93 added a commit that referenced this pull request Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Define behavior for special variables in remote Taskfiles

2 participants