Skip to content

USER_WORKING_DIR stops working in global tasks #2206

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

Closed
snakeego opened this issue Apr 24, 2025 · 2 comments
Closed

USER_WORKING_DIR stops working in global tasks #2206

snakeego opened this issue Apr 24, 2025 · 2 comments
Assignees
Labels
area: variables Changes related to variables.

Comments

@snakeego
Copy link

Description

Global tasks stop working in this scenario: https://taskfile.dev/usage/#running-a-global-taskfile.
This version doesn't change the ⁠USER_WORKING_DIR variable; it always keeps the ⁠$HOME directory.

Version

3.42.2

Operating system

MacOS

Experiments Enabled

No response

Example Taskfile

version: "3"

tasks:
  pwd:
    dir: '{{.USER_WORKING_DIR}}'
    cmds:
      - pwd
@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Apr 24, 2025
@vmaerten vmaerten added area: variables Changes related to variables. and removed state: needs triage Waiting to be triaged by a maintainer. labels Apr 24, 2025
@andreynering andreynering self-assigned this Apr 24, 2025
@cdmatta
Copy link

cdmatta commented Apr 24, 2025

Found that removing the conditional check here

task/setup.go

Lines 195 to 202 in 6cb0a5a

func (e *Executor) setupCompiler() error {
if e.UserWorkingDir == "" {
var err error
e.UserWorkingDir, err = os.Getwd()
if err != nil {
return err
}
}

and setting the UserWorkingDir to the os.Getwd()

Image

does make it work.

I don't know enough context about the entire possibilities with task, thus decided against making an MR. If you think this is indeed the fix, I can make an MR by investigating the tests (TestUserWorkingDirectoryWithIncluded needs to be updated)

@pd93
Copy link
Member

pd93 commented Apr 27, 2025

This was caused by #2186 which has been reverted in 68d5095 and released in v3.43.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: variables Changes related to variables.
Projects
None yet
Development

No branches or pull requests

6 participants