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

Ansible Lint fails to recognise yamllint installed by Homebrew on macOS #1722

Closed
jamesquilty opened this issue Sep 9, 2021 · 9 comments
Closed
Labels

Comments

@jamesquilty
Copy link

Summary

I've installed ansible-lint and yamllint with Homebrew on macOS, and also use an Arch Linux machine with ansible-lint installed (method unknown) and with yamllint installed by me using pip. I've found that ansible-lint reports yaml violations on Arch Linux machine but not on macOS. I think it's a fair conclusion that it's not finding yamllint at its brew-installed location /usr/local/bin/yamllint.

Issue Type
  • Bug Report
Ansible and Ansible Lint details
macOS: $ ansible --version
ansible [core 2.11.3]
  config file = None
  configured module search path = ['/Users/.../.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/4.3.0/libexec/lib/python3.9/site-packages/ansible
  ansible collection location = /Users/.../.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.6 (default, Jun 29 2021, 04:45:03) [Clang 11.0.0 (clang-1100.0.33.17)]
  jinja version = 3.0.1
  libyaml = True

macOS: $ ansible-lint --version
ansible-lint 5.1.2 using ansible 2.11.3
  • ansible installation method: OS package
  • ansible-lint installation method: OS package
OS / ENVIRONMENT

macOS 10.14.6 and 10.15.7

STEPS TO REPRODUCE

On macOS install via brew and try to lint a playbook with yaml rule violations. Assuming the working directory contains the playbook with violations

$ brew install ansible-lint
$ brew install yamllint
$ cd <path-to-playbook-with-yaml-issues>
$ ansible-lint  # produces no output
$ ansible-lint -t yaml  # produces no output
$ echo "enable_list:" >> .ansible-lint
$ echo "  - yaml" >> .ansible-lint
$ ansible-lint
Failed to load yamllint library and ansible-linted was configured to require it.
Desired Behaviour

ansible-lint should find the brew-installed yamllint and report yaml rule violations.

Actual Behaviour

Silent failure. This looks identical to "no rule violations" which makes it rather pernicious.

I think that the root of the problem is that, as of #953, ansible-lint sliently loses/acquires functionality depending on whether an external dependency (yamllint) can be found. That's a different issue.

@jamesquilty jamesquilty added bug new Triage required labels Sep 9, 2021
@webknjaz
Copy link
Member

webknjaz commented Sep 9, 2021

@jamesquilty typically, the executable lookup relies on the $PATH env var. Do you have the respective directory set in the globally available $PATH?

@jamesquilty
Copy link
Author

@webknjaz Yes, /usr/local/bin is listed at the top of /etc/paths, which is macOS's system-wide list of search path for commands, and I've confirmed that it's present in the PATH environment variable.

@konstruktoid
Copy link
Contributor

@jamesquilty could you paste the output of which yamllint && echo $PATH for the affected user?

@jamesquilty
Copy link
Author

@konstruktoid Sure, no probs.

$ which yamllint && echo $PATH
/usr/local/bin/yamllint
/Users/<username>/.pyenv/shims:/usr/local/opt/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Users/<username>/.gem/ruby/3.0.0/bin

The situation is that there are more than 30 users, running macOS, Windows and Linux, using ansible-lint on closely related repos. Some users' development environments are maintained by a sysadmin, so they have limited control of environment configuration. If ansible-lint behaves differently in different environments, then that's a problem - it's unfair to be told that your code contains linting rule violations that you were never shown!

I think that ansible-lint should either always lint YAML or never lint YAML; it should never sometimes lint YAML depending on the environment in which its run.

@ssbarnea ssbarnea removed the new Triage required label Sep 30, 2021
@ssbarnea
Copy link
Member

Closing as yamllint library is needed and presence or absence of executable does not affect linter behavior.

The reason why yamllint is a soft-dependency is licensing. Making yamllint a full-dependency would force ansible-lint license to become GPL.

@jamesquilty
Copy link
Author

The yamllint library certainly appears to be present in the brew install under /usr/local/Cellar/yamllint/1.26.3/libexec/lib/python3.9/site-packages/yamllint/ and everything created by a pip install is present there.

That's not actually relevant, though. The actual problem is the "soft-dependency", so as I indicated above I'll create a separate issue for that.

@kphatak
Copy link

kphatak commented Dec 15, 2022

I am still hitting this, any workaround?

@jamesquilty
Copy link
Author

@kphatak yes, I resolved several problems with Homebrew-installed Python packages by instead installing Python packages with pip. This worked-around the specific problem reported in this bug but also allowed version pinning of dependencies and the ability to easily back-out an update, amongst other benefits.

@ssbarnea
Copy link
Member

There is a reason why brew install is not listed as supported installation! I love brew and use it every day, but I do not maintain a recipe for linter, mainly due to lack of time to update it. Brew is high maintenance in that area as they did not provide any way to automate the update of recipes and testing. If someone wants, they are more welcome to take care of this aspect.

I guess that I will have to write a section about unsupported installers, like poetry and brew, to warn users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants