Skip to content
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

Temporary folder (.task) is not exposed as a special variable #1475

Closed
ssbarnea opened this issue Jan 18, 2024 · 3 comments
Closed

Temporary folder (.task) is not exposed as a special variable #1475

ssbarnea opened this issue Jan 18, 2024 · 3 comments

Comments

@ssbarnea
Copy link
Contributor

ssbarnea commented Jan 18, 2024

Most people would probably hardcode the .task in their config files but the few that use TASK_TEMP_DIR variable to customize it will have a problem as there is no special variable for the current value of the task temp directory.

Another thing that I find weird is that I did not see taskfile creating this folder and I was expecting that it would be automatically created when absent.

@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Jan 18, 2024
@pd93
Copy link
Member

pd93 commented Jan 18, 2024

Hi @ssbarnea, there is no special variable for TASK_TEMP_DIR. However, the value should still be accessible as the env is passed through to any tasks:

version: '3'

tasks:
  default:
    cmds:
      - echo $TASK_TEMP_DIR
      - echo {{.TASK_TEMP_DIR}}
> TASK_TEMP_DIR=".tasktest" task
task: [default] echo $TASK_TEMP_DIR
.tasktest
task: [default] echo .tasktest
.tasktest

Tested on v3.33.1

Another thing that I find weird is that I did not see taskfile creating this folder and I was expecting that it would be automatically created when absent.

The folder is also created for me when I run this task.

@diamondburned
Copy link

These behaviors are only true if TASK_TEMP_DIR is actually set. If not, .task is not automatically created, and the env var is empty when evaluated.

I think the issue was created because these wanted behaviors aren't performed with an unset TASK_TEMP_DIR when they should.

@vmaerten
Copy link
Member

vmaerten commented Jul 7, 2024

Hi,

As @pd93 said, the only way to override the temporary folder is with the TASK_TEMP_DIR environment variable. As all env variables are exposed in the templating system, you are able to do something like this :

version: '3'
vars:
  TASK_TEMP_DIR: '{{.TASK_TEMP_DIR | default ".task" }}'
tasks:
  default:
    cmds:
      - echo {{.TASK_TEMP_DIR}}

The folder is created no matter if TASK_TEMP_DIR is set or not, but it's only created if we need it (e.g: we need to store fingerprint and/or remote cache)

@vmaerten vmaerten closed this as completed Jul 7, 2024
@task-bot task-bot removed the state: needs triage Waiting to be triaged by a maintainer. label Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants