mschuchard / linter-ansible-linting

ansible-lint linter for pulsar

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Linting does not work on Mac

DaveMcBrave opened this issue · comments

I am using Mac OS X 10.10.5 and atom 1.6.2 and the linter does not work. It seems that it just does not start, but according to atom it is loaded. There is no way of selecting "ansible" as a language for files. I have the newest version of "ansible-lint" installed (2.4.2) and when I feed it YAML files via command line, it works fine.

I already tried to set the alternative rules path to "/Library/Python/2.7/packages/ansiblelint/rules", which is the one "ansible-lint" uses, but it still does not work.

I am new to atom and don't know how to debug this properly. Maybe you can advise me on how to get the information you need to help me.

It sounds like you need to install language-ansible and then select the ansible language from the lower right of Atom. The last released version of linter-ansible-linting would automatically install linter but not language-ansible. I have added the language-ansible dependency to the latest dev version, as well as the ability to lint all yaml files by default, so there are a couple of upstream fixes for this situation.

Please install language-ansible and select the ansible language. Let me know if that fixes it for you. There is a possibility you may need to specify the executable path for ansible-lint in the settings as previously Atom for Mac was notorious for not capturing the shell env on startup.

Installing language-ansible did the trick! Thanks for responding this quickly!

But I am not sure if the linting works as it's supposed to. When I deliberately insert errors into the code, they are not pointed out until I save the file. Even then the line in which the error is located is not marked.
screen shot 2016-04-07 at 14 36 14

If linter-ansible-syntax is activated additionally, the linting works. But the linter says that my files are not valid in ansible, but ansible works with them:
screen shot 2016-04-07 at 14 34 56
screen shot 2016-04-07 at 14 35 40

So there are a few things happening here:

  1. ansible-lint recently added an ansible syntax check as something it did before linting. If you have a syntax error in your playbook, then ansible-lint will fatally error. Please reference #3, ansible/ansible-lint#123, ansible/ansible-lint#125, and ansible/ansible-lint#126. I do not know if the cleaner exception he added in 126 is part of version 2.4.2, but it looks like your stack trace is rather messy so I assume no.
  2. You will not get lines of errors from ansible-lint. That is not a feature of it.
  3. linter-ansible-linting is a 'lint on save' linter and not 'lint on fly' so you will not see output before saving.
  4. I have no idea why adding my linter-ansible-syntax blocked the error output from ansible-lint. Sounds like magic.
  5. If linter-ansible-syntax claims you have a syntax error but Ansible is executing your playbook without error, please open an issue on its tracker and we can continue the discussion for it over there.

Okay, I finally understood what is wrong here and how linter-ansible-linting and linter-ansible-syntax work. Thank you for your help. It took me a while, but I learned a lot:

The Problem is that I set up Ansible, as suggested in http://docs.ansible.com/ansible/playbooks_best_practices.html, to work with include files. linter-ansible-syntax obviously had to display errors, because the include-files are no valid playbooks.

In conclusion there is nothing wrong with your packages. They are just not suitable for my Ansible setup, at this time. How would you handle working with include-files and still be able to enjoy your linter?

I have seen ansible-lint perform differently with my linter and includes. For example, if the include is missing the linter errors, if the include has style warnings then the linter displays those warnings in your current file, and all kinds of other stuff.

I have been mulling what to do about this ever since I received some additional information about this from Will. I think I will probably just end up blocking ansible-lint from linting includes within Atom, which is something I can do from within this package. Formerly I was contemplating doing something ambitious, but I think it will probably not be worth it.

Issue with linting includes finally fixed in 560a0ac.

I also confirmed the ansible-playbook --syntax-check is not checking includes so linter-ansible-syntax is fine as is.

Further improved in 5976802