ansible / vscode-ansible

vscode/vscodium extension for providing Ansible auto-completion and integrating quality assurance tools like ansible-lint, ansible syntax check, yamllint, molecule and ansible-test.
https://ansible.readthedocs.io/projects/vscode-ansible/
MIT License
360 stars 88 forks source link

Ansible Meta Data warns Ansible Lint missing #607

Closed sgreiner closed 2 years ago

sgreiner commented 2 years ago

Sanity check

Summary

"Ansible Meta data" warns that Ansible Lint is missing, but it is installed and working. I guess the extension is not finding the "python3" executable, it only tries "python" which an Ubuntu does not provide out of the box.

image image

Extension version

v0.12.30

VS Code version

1.70.2

Ansible Version

$ ansible --version
ansible [core 2.13.2]
  config file = /home/xx/projects/ansible/ansible.cfg
  configured module search path = ['/home/xx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/xx/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/xx/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/xx/.local/bin/ansible
  python version = 3.10.4 (main, Apr  2 2022, 09:04:19) [GCC 11.2.0]
  jinja version = 3.0.3
  libyaml = True

OS / Environment

Windows 11 Enterprise -> VS Code -> WSL Ubuntu 22.04 LTS

$ ansible-lint --version ansible-lint 6.0.2 using ansible 2.13.2

$ ansible --version | grep "python version" python version = 3.10.4 (main, Apr 2 2022, 09:04:19) [GCC 11.2.0]

Relevant log output

Path for lint:  /home/xx/.local/bin/ansible-lint
Validating using ansible-lint
cmd 'python --version' was not executed with the following error: ' Error: Command failed: python --version
/bin/sh: 1: python: not found

cmd 'ansible-lint --version' has the following error: WARNING: PATH altered to include /usr/bin

[Info  - 7:30:08 PM] [ansible-lint] WARNING: PATH altered to include /usr/bin
WARNING  Loading custom .yamllint config file, this extends our internal yamllint config.
sgreiner commented 2 years ago

After installing the python-is-python3 workaround package the warning "python: not found" was gone (wich is not really a desired fix for all people) But the warning is still thrown, that ansible-lint is missing.

This time the Ansible Server gives this output:

Path for lint:  /home/xx/.local/bin/ansible-lint
Validating using ansible-lint
cmd 'ansible-lint --version' has the following error: WARNING: PATH altered to include /usr/bin

[Info  - 8:00:01 PM] [ansible-lint] WARNING: PATH altered to include /usr/bin
WARNING  Loading custom .yamllint config file, this extends our internal yamllint config.

cmd 'ansible-lint --version' has the following error: WARNING: PATH altered to include /usr/bin

https://github.com/ansible/ansible-lint/issues/2357 There the issue is already mentioned.

WARNING Loading custom .yamllint config file, this extends our internal yamllint config. I guess this "warning" (which should not be a warning) will be the next reason why the Ansible Server will say that ansible-lint is not installed.

ssbarnea commented 2 years ago

Closing as we already released a fix for few days ago.

max06 commented 2 years ago

Closing as we already released a fix for few days ago.

Hey @ssbarnea, when do you expect this fix to arrive? As of v0.13.68 (pre-release) this issue still persists.

ssbarnea commented 2 years ago

Lets see what @priyamsahoo can say about it, maybe we failed to release ALS. He had few days of vacation but should be back next week. I will reopen the bug so we do not forget about it.

max06 commented 2 years ago

Thank you 🙇🏼

Linking #615 because it seems to be related. You can find a devcontainer in that one as well for reproducible testing.

jovmarkovic commented 2 years ago

Also I can confirm that the ansible-lint warning is happening on on 12.6 MacOS version. and here is my version below: Installed with brew install ansible && brew install ansible-lint


j.markovic@MacBook-Pro-2 ~ % ansible-lint --version
WARNING: PATH altered to include /opt/homebrew/Cellar/ansible-lint/6.6.0/libexec/bin
ansible-lint 6.6.0 using ansible 2.13.4
j.markovic@MacBook-Pro-2 ~ % ansible --version
ansible [core 2.13.4]
  config file = None
  configured module search path = ['/Users/j.markovic/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/Cellar/ansible/6.4.0/libexec/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/j.markovic/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.10.6 (main, Aug 30 2022, 04:58:14) [Clang 13.1.6 (clang-1316.0.21.2.5)]
  jinja version = 3.1.2
  libyaml = True
ssbarnea commented 2 years ago

I am currently unable to test with 12.6 as the upgrade from 12.5.1 was permanently failing for the last week. This morning we opened a support ticket with Apple after sending 0.5GB of logs.

Still, I doubt that the issue is specific to it. You should be able to guess the running which -a ansible-lint and which -a ansible, probably you have multiple versions in different locations.

jovmarkovic commented 2 years ago
j.markovic@MacBook-Pro-2 ~ % which -a ansible-lint && which -a ansible
/opt/homebrew/bin/ansible-lint
/opt/homebrew/bin/ansible

So, I have only one global version. I also use virtual envs but this should not be the issue for VSCode. Also the 12.6 is really unstable. Slack glitching, and also the browser. I also can't run as many VMs as I could using the same provisioner for molecule after the update with the same provider for vagrant, but that's a different topic

And here is the warning displayed. Maybe it helps

Screen Shot 2022-09-20 at 22 01 33
jovmarkovic commented 2 years ago

I have just noticed that I am using a different repo for the extension: https://github.com/ansible/vscode-ansible

Will this fix be Implemented there also, or should I create the bug report for that repo independently of this?

ssbarnea commented 2 years ago

@jovmarkovic This extension is built from two repositories. As long they are under Ansible organization, you are safe. It is not obvious if a bug is part of the client side or the language server, especially as some are combined.

BTW, I am currently working on a change in linter itself related to the way it finds ansible, one that should improve the experience for MacOS users in particular. See https://github.com/ansible/ansible-lint/pull/2477

jovmarkovic commented 2 years ago

@ssbarnea Perfect answer. Thank you

vrcs commented 1 year ago

Its still happening on Mac M2 installations

installed python3 ansible and ansible-lint using homebrew

userxxxx@mylocal_mac:~ $ which ansible-lint /usr/local/bin/ansible-lint userxxxx@mylocal_mac:~ $ ansible-lint --version ansible-lint 6.18.0 using ansible-core:2.15.3 ansible-compat:4.1.8 ruamel-yaml:0.17.32 ruamel-yaml-clib:0.2.7 userxxxx@mylocal_mac:~ $

userxxxx@mylocal_mac:~ $ ansible --version ansible [core 2.15.3] config file = /Users/userxxxx/repositories/ansible/ansible.cfg configured module search path = ['/Users/userxxxx/repositories/ansible/library'] ansible python module location = /usr/local/Cellar/ansible/8.3.0/libexec/lib/python3.11/site-packages/ansible ansible collection location = /Users/userxxxx/.ansible/collections:/usr/share/ansible/collections executable location = /usr/local/bin/ansible python version = 3.11.5 (main, Aug 24 2023, 15:18:16) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/usr/local/Cellar/ansible/8.3.0/libexec/bin/python) jinja version = 3.1.2 libyaml = True userxxxx@mylocal_mac:~ $

cmd 'ansible-lint --version' was not executed with the following error: ' TypeError: Cannot read properties of undefined (reading 'path') [Trace - 15:27:14] Received notification 'update/ansible-metadata'. Params: [ [ { "ansible information": { "core version": "2.15.3", "location": "/usr/local/Cellar/ansible/8.3.0/libexec/lib/python3.11/site-packages/ansible", "config file path": "/Users/userxxxx/repositories/ansible/ansible.cfg", "collections location": [ "/Users/userxxxx/.ansible/collections", "/usr/share/ansible/collections", "", "/usr/local/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python311.zip", "/usr/local/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11", "/usr/local/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/lib-dynload", "/usr/local/lib/python3.11/site-packages" ], "modules location": [ "/Users/userxxxx/repositories/ansible/library", "/usr/local/Cellar/ansible/8.3.0/libexec/lib/python3.11/site-packages/ansible/modules" ], "default host list path": [ "/Users/userxxxx/repositories/ansible/inventory" ] }, "python information": { "version": "3.11.5", "location": "/usr/local/opt/python@3.11/bin/python3.11" }, "ansible-lint information": {} } ] ]

Stil show warnings and the ansible-lint-information in the 'update/ansible-metadata'. is empty.

Screenshot 2023-09-06 at 15 44 25
CreativeWarlock commented 10 months ago

So this happens in my VS Code environment, too. VS Code version:

Version: 1.84.2 (user setup) Commit: 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e Date: 2023-11-09T10:51:52.184Z Electron: 25.9.2 ElectronBuildId: 24603566 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Windows_NT x64 10.0.19045


ansible@ubuntu-c:~$ which ansible-lint /usr/local/bin/ansible-lint

ansible@ubuntu-c:~$ ansible --version ansible [core 2.14.11] config file = None configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/local/lib/python3.10/dist-packages/ansible ansible collection location = /home/ansible/.ansible/collections:/usr/share/ansible/collections executable location = /usr/local/bin/ansible python version = 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] (/usr/bin/python3) jinja version = 3.1.2 libyaml = True

ansible@ubuntu-c:~$ ansible-lint --version ansible-lint 6.22.1 using ansible-core:2.14.11 ansible-compat:4.1.10 ruamel-yaml:0.18.5 ruamel-yaml-clib:0.2.8