Skip to content

Fix the handling of CLI option dir.#2703

Open
trulede wants to merge 1 commit intogo-task:mainfrom
trulede:PR/cli-dir
Open

Fix the handling of CLI option dir.#2703
trulede wants to merge 1 commit intogo-task:mainfrom
trulede:PR/cli-dir

Conversation

@trulede
Copy link
Contributor

@trulede trulede commented Feb 21, 2026

Values for --dir provided at the CLI are chomped in the call to getRootNode(). This means that the working dir for task is not actually set according to the user intention.

Grounding notes:

USER_WORKING_DIR = Directory task is called from. Fixed (does not change).
TASKFILE_DIR = Directory of the current taskfile (when running a task).
TASK_DIR = The working directory of a task.

  • defaults to c.Dir (which shadows e.Dir)
  • task.dir modifies -> join(c.Dir, task.Dir)
  • cli --dir modifies c.Dir (and thus may impact on previous line)

ROOT_DIR = Directory of the root taskfile. Fixed (does not change).

This PR fixes the chomping and ensures that a user (or test) provided --dir is used as the basis for determining a tasks working dir. If a task specifies a task.dir, that will be resolved relative to the provided --dir.

As a result of that change the RootDIr needs to be explicitly set, rather than inferred from c.Dir (which itself is set from e.Dir).

Observation: prior to this PR the dir cli option had no effect.

Note: one test needed modification because it was running in the ROOT_DIR rather than in the provided dir. This seems to have been a mistake in the test.

fixes #2102

Further observation: previous PR's have caused regressions. I do believe this change will be more resiliant.
68d5095

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

Successfully merging this pull request may close these issues.

Add special variable for task working directory

1 participant