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

Intermittent failure to find taskfile in subdirectory #1964

Closed
omusavi opened this issue Dec 17, 2024 · 3 comments
Closed

Intermittent failure to find taskfile in subdirectory #1964

omusavi opened this issue Dec 17, 2024 · 3 comments

Comments

@omusavi
Copy link

omusavi commented Dec 17, 2024

Description

Hi all,
Seeing some strange behavior with my taskfiles intermittently not being discovered. I am not sure if this is an environment issue or something related to the way I have configured by directories, and -v does not give any useful debugging information.

Occasionally, I will get stuck in a state where any task run in a directory that previously ran tasks fine just stops working. I have noticed this happening in times where there is no taskfile in the directory, but there is one in a root directory that is not being found. Here is some terminal output showing that:

vscode ➜ /workspaces/homelab/apps/paperless-ngx (apps-devexp) $ task up
task: [up] nomad job run -detach -address=http://127.0.0.1:4646  *.nomad.hcl
Job registration successful
Evaluation ID: 65dfbe65-6d95-acc2-7327-234e475dee92
vscode ➜ /workspaces/homelab/apps/paperless-ngx (apps-devexp) $ task up
task: No Taskfile found at "/workspaces/homelab/apps/paperless-ngx"
vscode ➜ /workspaces/homelab/apps/paperless-ngx (apps-devexp) $ task up
task: No Taskfile found at "/workspaces/homelab/apps/paperless-ngx"
vscode ➜ /workspaces/homelab/apps/paperless-ngx (apps-devexp) $ task up
task: No Taskfile found at "/workspaces/homelab/apps/paperless-ngx"
vscode ➜ /workspaces/homelab/apps/paperless-ngx (apps-devexp) $ task up
task: No Taskfile found at "/workspaces/homelab/apps/paperless-ngx"
vscode ➜ /workspaces/homelab/apps/paperless-ngx (apps-devexp) $ task
task: No Taskfile found at "/workspaces/homelab/apps/paperless-ngx"
vscode ➜ /workspaces/homelab/apps/paperless-ngx (apps-devexp) $ task -v
task: No Taskfile found at "/workspaces/homelab/apps/paperless-ngx"
vscode ➜ /workspaces/homelab/apps/paperless-ngx (apps-devexp) $ task --version
Task version: v3.40.1 (h1:Q/TjPh5SAI+XK2fBravDPZXNGm6mvnwrLJqCXfhZ3Wc=)
vscode ➜ /workspaces/homelab/apps/paperless-ngx (apps-devexp) $ task --list-all
task: Available tasks for this project:
# goes on to list all the tasks just fine

The first line everything works fine, I made no changes to the task files and when rerunning the same command, taskfiles are not found. After a while though, it will work again.

This is running in an Ubuntu 24.04 based VS Code devcontainer on a Mac OS device, I am not sure if that is related.

The structure of my taskfiles is the following, also not sure if its related:

apps/
├── paperless-ngx/
Taskfile.yml
tasks/
├── nomad.yml

The file nomad.yml contains the up task I am calling in the example above. It is included in the root Taskfile.yml as such:

includes:
  nomad:
    taskfile: tasks/nomad.yml
    flatten: true

And just in case it matters (I don't think it does because I have seen other similar subdirectory issues outside of this example):

  up:
    desc: Run the nomad job defined in the current directory
    dir: "{{.NOMAD_DIR | default .USER_WORKING_DIR}}"
    cmds:
      - nomad job run -detach -address={{.NOMAD_ADDR}} {{.NOMAD_FLAGS}} *.nomad.hcl

Looking at where this error is thrown I am not seeing where there might be an intermittent issue, but I am hoping you all can help me debug this!

Maybe simpler repro

Simple example of how a parent directory task is not being called read when in this state:

vscode ➜ /workspaces/homelab (apps-devexp) $ task --list-all
task: Available tasks for this project:
[REDACTED]
vscode ➜ /workspaces/homelab (apps-devexp) $ cd apps
vscode ➜ /workspaces/homelab/apps (apps-devexp) $ task --list-all
task: No Taskfile found at "/workspaces/homelab/apps"

Thanks!

Version

3.40.1

Operating system

Ubuntu 24.04

Experiments Enabled

No response

Example Taskfile

@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Dec 17, 2024
@trulede
Copy link

trulede commented Dec 18, 2024

If you replace the nomad command with something else (echo "foo"), I guess you don't see the problem anymore. Right?

@trulede
Copy link

trulede commented Dec 18, 2024

This may also be a factor, especially in your second case:

// directory. On supported operating systems, it will also check if the user ID

On supported operating systems, it will also check if the user ID of the directory changes and abort if it does.

@omusavi
Copy link
Author

omusavi commented Dec 19, 2024

Hey @trulede thanks for responding

This may also be a factor, especially in your second case:

task/taskfile/taskfile.go

Line 131 in f331726

// directory. On supported operating systems, it will also check if the user ID

On supported operating systems, it will also check if the user ID of the directory changes and abort if it does.

Looks like this might actually be the case, I did a chown -R vscode . on the root of my project directory and that at least unblocked the tasks from not walking the tree. When I originally did ls -la it showed .. as owned by root so I am guessing thats why the walk would immediately fail.

I am unsure why the directory was setup like that, and what was changing the permissions, but at least I have a workaround for now. My guess is this is something related to devcontainers more than the commands I was running. I will close this issue for now, but if it happens again I will post updates on what I find in case there is a fix to be made.

Thanks!!

@omusavi omusavi closed this as completed Dec 19, 2024
@task-bot task-bot removed the state: needs triage Waiting to be triaged by a maintainer. label Dec 19, 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

3 participants