You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
env: is not being expanded, so stuff like ~ isn't working there #185
I get the fallowing output (minus the -----> expected appended) when I run $ task test:
echo$HOME
/Users/ilyes512
echo~
/Users/ilyes512
echo$WORLD
world!!!!!echo$HW
hello_${WORLD} -----> expected: hello_world!!!!!echo$TEST_FILE~/testfile.txt
echo~/testfile.txt
/Users/ilyes512/testfile.txt
cat ~/testfile.txt
hello world
echo${TEST_FILE}~/testfile.txt -----> expected: /Users/ilyes512/testfile.txt
cat ${TEST_FILE}
cat: ~/testfile.txt: No such file or directory -----> expected: hello world
When I set an env variable like this (and I don't even use it):
env:
EXAMPLE: ${HOME}/foobar
It will error with:
"{HOME}/foobar": executable file not found in$PATH
task: Command "{HOME}/foobar"in taskvars file failed: exit status 127
So should I be able to use a earlier set env variable in another env?
Does the ~ and ${HOME} behave correctly?
Another issue I saw about almost the same thing: #74 It also mentions a "chat". Is this still in use, and if so, it should be documented somewhere? (would expect the readme to mention it).
BTW I have tried variables as both ${FOOBAR} as well as $FOOBAR (so minus the { and }).
changed the title [-]String interpolation and home dir (including ~)[/-][+]env: is not being expanded, so stuff like ~ is working there[/+]on Mar 9, 2019
changed the title [-]env: is not being expanded, so stuff like ~ is working there[/-][+]env: is not being expanded, so stuff like ~ isn't working there[/+]on Mar 9, 2019
We had a chat room in the past here (you'd need to sign up on https://gophers.slack.com first). It's still there, but I removed the links from the GitHub repo and site because I not always had time to answer questions quickly, and also it's not very searchable. GitHub issues suits better, IMHO.
About the issues you've being having... that's happening because Task isn't currently expanding values on env: at all. Expanding are only happening for dir: and sources: and generates:, so stuff like ~ will work there. But I think it makes sense to also expand env:, so I'll look into fixing this soon.
Even then, you still won't be able to reference other environment variables add to env:, though. Unless it's a previously set one, like PATH, etc.
If Minikube is not running it would stop execution with: 💣 Error getting IP: Host is not running which is fine, but would be nicer to do this in the task explicitly. Another great addition might be something like a condition key. A sort of check if the task deps are met:
hmm, but then again, having an easy to understand, not bloated task runner, is very nice as well. Could probably come up with 10's of idea's. A more generic way would maybe be a before_cmds and after_cmds (with the last one always beging run even when cmds errors, but not if before_cmds errored).
@Ilyes512 Yeah, I try not to add lots of features, but keep Task concise when possible.
For now, you can use Bash to check if the executable is available, and do nothing if don't. (The commands inside cmds and sh are interpreted as Bash commands, so you can use if, test, [], etc).
It's a common use case for js projects. Bun, dotenv, node all support this. I guess the alternative with taskfile is now as below but that's too repetitive when you need many env vars.
Activity
[-]String interpolation and home dir (including ~)[/-][+]env: is not being expanded, so stuff like ~ is working there[/+][-]env: is not being expanded, so stuff like ~ is working there[/-][+]env: is not being expanded, so stuff like ~ isn't working there[/+]andreynering commentedon Mar 9, 2019
Hi @Ilyes512,
We had a chat room in the past here (you'd need to sign up on https://gophers.slack.com first). It's still there, but I removed the links from the GitHub repo and site because I not always had time to answer questions quickly, and also it's not very searchable. GitHub issues suits better, IMHO.
About the issues you've being having... that's happening because Task isn't currently expanding values on
env:at all. Expanding are only happening fordir:andsources:andgenerates:, so stuff like~will work there. But I think it makes sense to also expandenv:, so I'll look into fixing this soon.Even then, you still won't be able to reference other environment variables add to
env:, though. Unless it's a previously set one, likePATH, etc.andreynering commentedon Mar 9, 2019
Keep in mind variable expansion works for
env:, too. That is likely to solve your use case already.Ilyes512 commentedon Mar 9, 2019
Yes, I was just now playing with vars instead and I realise I wouldn't actually use env variables that much.
I also noticed I can use vars to "build" env variables when needed ie:
BTW I am already am a member of gophers :)
Ilyes512 commentedon Mar 11, 2019
This might be it's own issue but I was wondering what your thought are about adding this:
If Minikube is not running it would stop execution with:
💣 Error getting IP: Host is not runningwhich is fine, but would be nicer to do this in the task explicitly. Another great addition might be something like aconditionkey. A sort of check if the task deps are met:hmm, but then again, having an easy to understand, not bloated task runner, is very nice as well. Could probably come up with 10's of idea's. A more generic way would maybe be a
before_cmdsandafter_cmds(with the last one always beging run even whencmdserrors, but not ifbefore_cmdserrored).andreynering commentedon Mar 16, 2019
@Ilyes512 Yeah, I try not to add lots of features, but keep Task concise when possible.
For now, you can use Bash to check if the executable is available, and do nothing if don't. (The commands inside
cmdsandshare interpreted as Bash commands, so you can useif,test,[], etc).snoob commentedon Jun 13, 2021
@andreynering Maybe home expanding is missing for includes too no ?
amancevice commentedon Jul 28, 2021
Expanding
~in includes would be great:MansurAliKoroglu commentedon Jan 29, 2026
I think it's good to have env expanding like below:
It's a common use case for js projects. Bun, dotenv, node all support this. I guess the alternative with taskfile is now as below but that's too repetitive when you need many env vars.
trulede commentedon Feb 1, 2026
This issue is in the weeds. As correctly noted, use vars and templating as much as possible.
For the original problem, prefix you command with eval to expand the envars:
eval echo $HW