Skip to content

.taskrc.yml and .env not found when in a sub folder #2159

@joeblew999

Description

@joeblew999

Description

I have a mono repo, and from down in a sub folder the .taskrc.yml and .env is not seen.

Like this pattern: https://taskfile.dev/usage/#running-a-taskfile-from-a-subdirectory

.taskrc.yml MUST be in the sub folder in order to be seen by TASK.

.env must be in the sub folder to be seen by TASK.

I was hoping that I could inherit these things from the root folder, and then just add a .env further down where I want to override things up in the root ...

Reproduction

Here is a set of examples: https://github.com/joeblew999/pb-stack/tree/main/proj

Each showing the commands to run to see the errors with each permutation. This should be an easy way to reproduce the issue.

Version

v3.42.1

Operating system

darwin

Experiments Enabled

Env Precedence, Map Variables (2), Gentle Force, Remote Taskfiles

Example Taskfile

# https://taskfile.dev

# todo

version: '3'

# MUST have this ONLY in root for env variables to work.
#dotenv: ['.env', '{{.ENV}}/.env', '{{.HOME}}/.env']

includes:
  # base for devtime
  base: ./../../base.taskfile.yml

  git: ./../../git.taskfile.yml
  go: ./../../go.taskfile.yml
  #vscode: ./vscode.taskfile.yml

  remote:
    # binary needed: https://github.com/aquasecurity/trivy/releases/tag/v0.60.0
    # https://github.com/saydulaev/taskfile
    taskfile: https://raw.githubusercontent.com/saydulaev/taskfile/v1.4.3/Taskfile.yml

vars:
  BASE_SRC_NAME: todo
  TODO_GREETING: Hello, from todo project !
 
tasks:
  default:
    desc: todo print
    cmds:
      - echo "{{.TODO_GREETING}}"
    silent: true
  bin:
    cmds:
      - task go:bin

.taskrc.yml file

# .task-experiments.yml
# If .env and .task-experiments.yml are present the values in the .task-experiments.yml file take precedence.

experiments:
  
  # https://taskfile.dev/experiments/env-precedence
  ENV_PRECEDENCE: 1

  # https://taskfile.dev/experiments/gentle-force/
  GENTLE_FORCE: 1

  # https://taskfile.dev/experiments/map-variables/?proposal=2
  MAP_VARIABLES: 2

  # https://taskfile.dev/experiments/remote-taskfiles/
  REMOTE_TASKFILES: 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: readerChanges related to the Taskfile reader.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions