A typical workflow involving .env files is:
.env is in .gitignore.env.example file.env from .env.example in the developers environmentI would like to use task instead of make, and as part of that I need to use task for my project's "first run" script -- which creates the .env file. Unfortunately, task throws an error because .env doesn't yet exist.
version: '3'
dotenv: ['.env']
tasks:
default:
cmds:
- cp -n .env.example .env # contrived example
open .env: no such file or directory
There's an issue in the godotenv project (https://github.com/joho/godotenv/issues/99) associated with this use-case as the error is being thrown by that library, however I've noticed in the tests for task it is explicitly intended that an error is thrown when the .env file does not exist.
Once the issue is fixed in godotenv it would be good to have the intended behaviour of task reviewed -- https://github.com/go-task/task/blob/master/task_test.go#L832
This is blocking for us as well.
We moved from Makefile to Taskfile but taskfile has .env as mandatory.
We used following code in Makefile.
-include .env
export
equivalent is not available in taskfile, when developer misses to checkin empty .env file, CI fails.
I missed this scenario when I was testing. I will push a PR in a day or two.
Hi @shrink, thanks for opening this issue!
This suggestion is reasonable indeed
This is now fixed in master
Most helpful comment
This is now fixed in master