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

ignore-from-file should use path of .yamllint.yaml as base, not current working dir #673

Open
jellehelsen opened this issue May 27, 2024 · 2 comments

Comments

@jellehelsen
Copy link

If there is a .yamllint.yaml at the base of the git repo, with ignore-from-file pointing to .gitignore, yamllint stops working in subdirectories. It will pickup the .yamllint.yaml file in a higher level directory, but then tries to find .gitignore in the current folder. This causes it to fail with FileNotFoundError: [Errno 2] No such file or directory: '.gitignore' .

Making this extra annoying is that editor plugins like flycheck, that use yamllint, tend to use the directory where the file is located as the working dir. So having ignore-from-file in your project level .yamllint.yaml breaks in-editor linting.

@adrienverge
Copy link
Owner

Hello and thanks for the report.

Yamllint doesn't handle Git repos differently than regular directories: if ignore-from-file points to a relative file, it will be searched from the current working directory. Looking for the ignore file in special locations (e.g. looking for a Git repo root in parent directories) would change current behavior and might annoy some users.

I suggest configuring flycheck to work like most Unix tools (if possible of course). Or maybe use an absolute path in ignore-from-file?

@jellehelsen
Copy link
Author

It's not really git related. Imho it does not make sense use the .yamllint.yaml that is in a parent directory and then fail because it can't find the ignore-from-file that is in that same folder.
Either don't use the .yamllint.yaml from a parent directory, or also find the files the .yamllint.yaml points to with a relative path. In the latter case the relative path should be relative to the .yamllint.yaml that is pointing to it.
In the current implementation, yamllint breaks when you go into a child folder.

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
@jellehelsen @adrienverge and others