-
-
Notifications
You must be signed in to change notification settings - Fork 641
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
Twice-included Taskfiles have incorrect directory as TASKFILE_DIR as well as pwd output #1301
Comments
Came across the same issue! |
Same issue for me, any update? |
I managed to reproduce the issue, but couldn't quickly find the cause of the problem. |
The issue is with chains of includes in general.
Here's a little experiment. Download the attachment (taskfiles.zip) or create a folder hierarchy like
version: '3'
output: prefixed
includes:
sub1:
taskfile: ./sub1/Sub1Tasks.yml
dir: ./sub1
sub2:
taskfile: ./sub1/sub2/Sub2Tasks.yml
dir: ./sub1/sub2
tasks:
default:
cmds:
- task: echo
- task: sub1:echo
- task: sub2:echo
- task: sub1:sub2:echo
silent: true
echo:
cmds:
- 'echo ".TASKFILE_DIR: {{.TASKFILE_DIR}}"'
- 'echo " \$PWD: $PWD"'
- 'echo " pwd: $(pwd)"'
silent: true
version: '3'
includes:
sub2:
taskfile: ./sub2/Sub2Tasks.yml
dir: ./sub2 # Will be ignored by .TASKFILE_DIR
tasks:
echo:
cmds:
- 'echo ".TASKFILE_DIR: {{.TASKFILE_DIR}}"'
- 'echo " \$PWD: $PWD"'
- 'echo " pwd: $(pwd)"'
silent: true
version: '3'
vars:
PWD_OUTPUT:
sh: pwd
tasks:
echo:
cmds:
- 'echo ".TASKFILE_DIR: {{.TASKFILE_DIR}}"'
- 'echo " \$PWD: $PWD"'
- 'echo " pwd: $(pwd)"'
- 'echo " .PWD_OUTPUT: {{.PWD_OUTPUT}}"'
silent: true Then execute: $ task
[echo] .TASKFILE_DIR: /home/some.guy/src/taskfiles
[echo] $PWD: /home/some.guy/src/taskfiles
[echo] pwd: /home/some.guy/src/taskfiles
[sub1:echo] .TASKFILE_DIR: /home/some.guy/src/taskfiles/sub1
[sub1:echo] $PWD: /home/some.guy/src/taskfiles/sub1
[sub1:echo] pwd: /home/some.guy/src/taskfiles/sub1
[sub2:echo] .TASKFILE_DIR: /home/some.guy/src/taskfiles/sub1/sub2
[sub2:echo] $PWD: /home/some.guy/src/taskfiles/sub1/sub2
[sub2:echo] pwd: /home/some.guy/src/taskfiles/sub1/sub2
[sub2:echo] .PWD_OUTPUT: /home/some.guy/src/taskfiles/sub1/sub2
[sub1:sub2:echo] .TASKFILE_DIR: /home/some.guy/src/taskfiles/sub1 <-- Look here!
[sub1:sub2:echo] $PWD: /home/some.guy/src/taskfiles/sub1/sub2
[sub1:sub2:echo] pwd: /home/some.guy/src/taskfiles/sub1/sub2
[sub1:sub2:echo] .PWD_OUTPUT: /home/some.guy/src/taskfiles/sub1/sub2
Now comment out the $ task
[echo] .TASKFILE_DIR: /home/some.guy/src/taskfiles
[echo] $PWD: /home/some.guy/src/taskfiles
[echo] pwd: /home/some.guy/src/taskfiles
[sub1:echo] .TASKFILE_DIR: /home/some.guy/src/taskfiles
[sub1:echo] $PWD: /home/some.guy/src/taskfiles
[sub1:echo] pwd: /home/some.guy/src/taskfiles
[sub2:echo] .TASKFILE_DIR: /home/some.guy/src/taskfiles
[sub2:echo] $PWD: /home/some.guy/src/taskfiles
[sub2:echo] pwd: /home/some.guy/src/taskfiles
[sub2:echo] .PWD_OUTPUT: /home/some.guy/src/taskfiles
[sub1:sub2:echo] .TASKFILE_DIR: /home/some.guy/src/taskfiles
[sub1:sub2:echo] $PWD: /home/some.guy/src/taskfiles/sub1/sub2
[sub1:sub2:echo] pwd: /home/some.guy/src/taskfiles/sub1/sub2
[sub1:sub2:echo] .PWD_OUTPUT: /home/some.guy/src/taskfiles
Circling back to the original complaint:
|
For nested
version: '3'
includes: ./tasks
version: '3'
includes: ./subject # <-- case 1 included via shorthand
version: '3'
tasks:
hello:
cmds:
# expect same output regardless of how Taskfile is included
- realpath .
- echo TASKFILE_DIR {{.TASKFILE_DIR}} Output case 1 (shorthand)I expect to see
Case 2 (longhand)Then for case 2 I change version: '3'
includes:
taskfile: ./subject # <-- case 2 included via longhand Output case 2Same expectations, but now both outputs seem wrong, although
|
Has anyone found a workaround to this issue? Feel super painful. |
An unintended side-effect of the v3.35.1 release is that this is now working as expected for the examples in #1301 (comment) and #1301 (comment). This is because @explosivose, I was not able to replicate your specific example. Mainly because as far as I can tell, the shorthand syntax for |
@pd93 bumping to |
I have a
Taskfile.dist.yml
file that is checked into the git repository. This Taskfile includes anotherTaskfile.dist.yml
from/frontend
.This file has a variable that depends on the current directory being
/frontend
.This setup works fine.
I now want to create a local
Taskfile.yml
with my custom commands.In that file, I include
Taskfile.dist.yml
. I can call the functions from the taskfile infrontend
. However, the variable now has an incorrect directory, it uses/
.Reproducable example
Taskfiles
Taskfile.yml
Taskfile.dist.yml
frontend/Taskfile.dist.yml
Shell commands and incorrect result
Actual
When the command is run from
Taskfile.dist.yml
, the output frompwd
as well as theTASKFILE_DIR
variable end with/frontend
. When it's run fromTaskfile.yml
, it's the same asROOT_DIR
.Expected
The result of the same task (
dist:frontend:where-am-I
andfrontend:where-am-I
) from both Taskfiles (Taskfile.yml
andTaskfile.dist.yml
) should return the correct subfolder forTASKFILE_DIR
andpwd
instead of the root folder:3.28.0
macOS Ventura 13.5 (22G74)
The text was updated successfully, but these errors were encountered: