- Task version: 2.5.1
- OS: Windows 10 Professional (64-bit)
- Example Taskfile showing the issue:
# https://taskfile.dev
version: '2'
tasks:
a:
cmds:
- echo "Task a"
- echo $PATH
b:
cmds:
- echo "Task b"
- echo "{{.PATH}}"
c:
env:
PATH: tools
cmds:
- echo "Task c"
- echo $PATH
d:
env:
PATH: tools
cmds:
- echo "Task d"
- echo "{{.PATH}}"
e:
env:
PATH:
sh: echo "tools;$PATH"
cmds:
- echo "Task e"
- echo $PATH
f:
env:
PATH:
sh: echo "./tools;$PATH"
cmds:
- echo "Task f"
- echo $PATH
g:
env:
PATH:
sh: echo "$(realpath ./tools);$PATH"
cmds:
- echo "Task g"
- echo $PATH
Hello. Firstly, thank-you for Task. It has, overall, made my development life easier and more pleasant.
I don't know if the problem I have is a bug or if I simply don't understand the correct way to achieve my goal. I'd like to be able to modify the environment variable PATH (either prepending or appending a project-specific directory to the existing value), but I can't figure out how to do this using the set of commands available within Taskfiles.
To provide context, my Taskfile is for use in building go applications. Some applications (projects) require project-specific build tools/helpers that I place in a top-level tools subdirectory (i.e., <project name>/tools). Note that my Taskfile resides at <project name>/Taskfile.yml. I wish to use the go generate command, which effectively requires that external generation tools be accessible via PATH, so I must add <project name>/tools to PATH before running go generate in the task.
While I'm working in Windows, I'm making effective use of busybox-w32 to provide a fairly comprehensive set of what are otherwise Linux tools, so things like cp, echo and realpath are available. I've also tried this via WSL such that things are more like a real Linux environment, with the same results.
The output I get from the above Taskfile (when run under sh or bash via WSL) is as follows (results in native Windows are the same):
$ task a; task b; task c; task d; task e; task f; task g
echo "Task a"
Task a
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
echo "Task b"
Task b
echo "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
echo "Task c"
Task c
echo $PATH
tools
echo "Task d"
Task d
echo "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
echo "Task e"
Task e
echo $PATH
tools;/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
echo "Task f"
Task f
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
echo "Task g"
Task g
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
Tasks a, b, c and d are just simple tests; it's tasks e, f and g that illustrate the real issue. Task e works correctly, prepending tools to the current PATH, but neither f nor g have any effect. Task g is the closest to what I need in terms of operations (i.e., adding the absolute path of a project-specific directory).
I'd greatly appreciate any input you could provide on this issue. Thanks in advance.
Hello. Firstly, thank-you for Task. It has, overall, made my development life easier and more pleasant.
I don't know if the problem I have is a bug or if I simply don't understand the correct way to achieve my goal. I'd like to be able to modify the environment variable
PATH(either prepending or appending a project-specific directory to the existing value), but I can't figure out how to do this using the set of commands available withinTaskfiles.To provide context, my
Taskfileis for use in building go applications. Some applications (projects) require project-specific build tools/helpers that I place in a top-leveltoolssubdirectory (i.e.,<project name>/tools). Note that myTaskfileresides at<project name>/Taskfile.yml. I wish to use thego generatecommand, which effectively requires that external generation tools be accessible viaPATH, so I must add<project name>/toolstoPATHbefore runninggo generatein the task.While I'm working in Windows, I'm making effective use of busybox-w32 to provide a fairly comprehensive set of what are otherwise Linux tools, so things like
cp,echoandrealpathare available. I've also tried this viaWSLsuch that things are more like a real Linux environment, with the same results.The output I get from the above Taskfile (when run under
shorbashviaWSL) is as follows (results in native Windows are the same):Tasks
a,b,canddare just simple tests; it's taskse,fandgthat illustrate the real issue. Taskeworks correctly, prependingtoolsto the currentPATH, but neitherfnorghave any effect. Taskgis the closest to what I need in terms of operations (i.e., adding the absolute path of a project-specific directory).I'd greatly appreciate any input you could provide on this issue. Thanks in advance.