Skip to content

Conversation

@trulede
Copy link
Contributor

@trulede trulede commented Jan 18, 2026

When task starts wthout a taskfile specified the entrypoint will be either the parameter --taskfile, which may be a directory, or the current directory. In such cases task will search for the taskfile to use. When that taskfile is found, the e.Entrypoint needs to be updated to reflect the resolved entrypoint.

Remarkably, this was not just broken, but really broken:

@blue:~/git/task/ISSUES$ task -t 1706 who-am-i
USER_WORKING_DIR = /home/blue/git/task/ISSUES
   ROOT_TASKFILE = /home/blue/git/task/ISSUES/1706/1706
        ROOT_DIR = /home/blue/git/task/ISSUES/1706
        TASKFILE = /home/blue/git/task/ISSUES/1706/Taskfile.yml
            TASK = who-am-i

even more remarkable, fixing the issue does not break any tests. The corrected output:

@blue:~/git/task/ISSUES$ task -t 1706 who-am-i
USER_WORKING_DIR = /home/blue/git/task/ISSUES
   ROOT_TASKFILE = /home/blue/git/task/ISSUES/1706/Taskfile.yml
        ROOT_DIR = /home/blue/git/task/ISSUES/1706
        TASKFILE = /home/blue/git/task/ISSUES/1706/Taskfile.yml
            TASK = who-am-i

The following taskfile used:

version: '3'

silent: true

tasks:
  who-am-i:
    cmds:
      - echo "USER_WORKING_DIR = {{.USER_WORKING_DIR}}"
      - echo "   ROOT_TASKFILE = {{.ROOT_TASKFILE}}"
      - echo "        ROOT_DIR = {{.ROOT_DIR}}"
      - echo "        TASKFILE = {{.TASKFILE}}"
      - echo "            TASK = {{.TASK}}"

fixes #1706
closes #1708

@vmaerten vmaerten self-requested a review January 25, 2026 15:03
Copy link
Member

@vmaerten vmaerten left a comment

Choose a reason for hiding this comment

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

Way better than my previous solution!
Thanks!

I've just added a test

@vmaerten vmaerten changed the title Correct the value of ROOT_TASKFILE fix: correct the value of ROOT_TASKFILE when no entrypoint Jan 25, 2026
@vmaerten vmaerten merged commit 1bd5aa6 into go-task:main Jan 25, 2026
14 checks passed
vmaerten added a commit that referenced this pull request Jan 25, 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.

.ROOT_TASKFILE returns the root directory instead of the file

2 participants