Closed kimbernator closed 3 years ago
The thing is that you have both Python 2 and Python 3 installed on your OS. The reason python
has been replaced with python3
was precisely for the extension to work correctly in such environments. In those environments python
is resolved to Python 2, hence the error.
For some reason python3
is not resolved to Python 3 in your environment - this is what you should try to fix. You may either add python3
to your PATH
; or provide full path to your Python 3 interpreter in the extension options (the folder containing the interpreter should contain python3
- which it always does in case of Python 3 installations).
The issue ended up being a little different; the directory that contained my collections/roles/etc wasn't actually in python3's sys.path. I don't know if I had just set a custom path for ansible-galaxy to store that stuff and never accounted for it or something, but I fixed this by adding a new ".pth" file (arbitrarily named ansible.pth
) to my site-packages
directory that contained the path to my ansible directory.
With that done, everything works perfectly (including autocomplete, which never worked in any state for me)
Summary
I noticed that recently my syntax highlighting for ansible files is pretty much just YAML with jinja expression highlighting without any of the especially useful features of this extension.
For example, here's what I would expect to see:
But here is what I actually see:
Hovering on
reboot
will no longer provide information about that resource and keywords are no longer highlighted.I went back and kept installing older versions of the extension until I got to 1.0.1, which is where the highlighting started working again. I can see that the only functional change from 1.0.1->1.0.2 was in https://github.com/tomaciazek/vscode-ansible/pull/7, where the
python
command to get the PATH was modified to usepython3
instead because of a syntax error. For kicks, I opened the minified server.js from the installed 1.0.4 and found the"python3"
string, modified it to"python"
again, then reloaded the workspace and found that full syntax highlighting had returned in addition to the error it was intended to solve:Extension version
>=1.0.2
VS Code version
1.58.2
Ansible Version
OS / Environment
MacOS 11.5.1
Relevant log output
No response