Description
When a dotenv path references a variable computed via sh, the template renders incorrectly — the variable appears empty, causing the resolved path to fall back to the task's working directory.
Expected behavior
{{.DOTENV}} resolves to the output of mktemp and the dotenv file at that path is loaded.
Actual behavior
{{.DOTENV}} renders to an empty string. The empty path is resolved against the task's working directory.
$ task
task: Failed to read env file ...: read /home/user/project: is a directory
Related issues
Workaround
Avoid dotenv entirely and source the file explicitly in each task that needs it:
cmds:
- |
set -a && source {{.DOTENV}} && set +a
Version
3.48.0
Operating system
Ubuntu 20.04
Experiments Enabled
No response
Example Taskfile
version: '3'
vars:
DOTENV:
sh: mktemp
tasks:
default:
dotenv:
- '{{.DOTENV}}'
cmds:
- echo "AWS_KEY=$AWS_KEY"
Description
When a
dotenvpath references a variable computed viash, the template renders incorrectly — the variable appears empty, causing the resolved path to fall back to the task's working directory.Expected behavior
{{.DOTENV}}resolves to the output ofmktempand the dotenv file at that path is loaded.Actual behavior
{{.DOTENV}}renders to an empty string. The empty path is resolved against the task's working directory.Related issues
Workaround
Avoid
dotenventirely and source the file explicitly in each task that needs it:Version
3.48.0
Operating system
Ubuntu 20.04
Experiments Enabled
No response
Example Taskfile