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

Warning is displayed if installed in separate virtual environment #2538

Closed
Vanav opened this issue Oct 2, 2022 · 3 comments
Closed

Warning is displayed if installed in separate virtual environment #2538

Vanav opened this issue Oct 2, 2022 · 3 comments
Labels

Comments

@Vanav
Copy link

Vanav commented Oct 2, 2022

If ansible-lint is installed in separate virtual environment via pipx, I got warning:

# ansible-lint
WARNING: PATH altered to include /opt/pipx/venvs/ansible-lint/bin :: This is usually a sign of broken local setup, which can cause unexpected behaviors.

I think, separate virtual environment is a good way to install and update Python apps, because there will be no issues with dependencies and versions, so there should be no warning in this case.

# ls -al /opt/pipx/venvs/ansible-lint/bin
total 96
-rw-r--r-- 1 root root 1911 Aug 23 23:16 activate
-rw-r--r-- 1 root root  860 Aug 23 23:16 activate.csh
-rw-r--r-- 1 root root 2000 Aug 23 23:16 activate.fish
-rw-r--r-- 1 root root 8834 Aug 23 23:16 Activate.ps1
-rwxr-xr-x 1 root root  239 Aug 23 23:16 ansible
-rwxr-xr-x 1 root root  240 Aug 23 23:16 ansible-config
-rwxr-xr-x 1 root root  269 Aug 23 23:16 ansible-connection
-rwxr-xr-x 1 root root  241 Aug 23 23:16 ansible-console
-rwxr-xr-x 1 root root  237 Aug 23 23:16 ansible-doc
-rwxr-xr-x 1 root root  240 Aug 23 23:16 ansible-galaxy
-rwxr-xr-x 1 root root  243 Aug 23 23:16 ansible-inventory
-rwxr-xr-x 1 root root  272 Sep 26 13:20 ansible-lint
-rwxr-xr-x 1 root root  242 Aug 23 23:16 ansible-playbook
-rwxr-xr-x 1 root root  238 Aug 23 23:16 ansible-pull
-rwxr-xr-x 1 root root 1723 Aug 23 23:16 ansible-test
-rwxr-xr-x 1 root root  239 Aug 23 23:16 ansible-vault
-rwxr-xr-x 1 root root  243 Sep  2 15:35 black
-rwxr-xr-x 1 root root  244 Sep  2 15:35 blackd
-rwxr-xr-x 1 root root  238 Aug 23 23:16 cmark
-rwxr-xr-x 1 root root  236 Aug 23 23:16 jsonschema
-rwxr-xr-x 1 root root  238 Aug 23 23:16 pygmentize
lrwxrwxrwx 1 root root    9 Aug 23 23:16 python -> python3.9
lrwxrwxrwx 1 root root    9 Aug 23 23:16 python3 -> python3.9
lrwxrwxrwx 1 root root   18 Aug 23 23:16 python3.9 -> /usr/bin/python3.9
-rwxr-xr-x 1 root root  232 Aug 23 23:16 yamllint
@Vanav Vanav added bug new Triage required labels Oct 2, 2022
@ssbarnea ssbarnea removed the new Triage required label Oct 3, 2022
@ssbarnea
Copy link
Member

ssbarnea commented Oct 3, 2022

That warning was added on purpose because we do rely on a lot of code from Ansible itself and calling without activating virtualenvs might make us call two different versions of ansible, only via command line and one via python imports.

This warning is there to stay, it just reminds you that it will only look for ansible installed from inside the same environment, so you do get surprised that... is not the same ansible as the one you call directly.

And, yep, you are right that using pipx and venvs is a good practice, at least for most cases.

@ssbarnea ssbarnea closed this as not planned Won't fix, can't repro, duplicate, stale Oct 3, 2022
@stefan-as
Copy link

Out of curiosity: Why is ansible-lint calling ansible via command line? What is the use cases to do so? And even if there are these use cases, it is not a big deal to call ansible runs programmatically:

from ansible.cli.playbook import PlaybookCLI

def run(args):
    cli = PlaybookCLI(args)
    cli.parse()
    return cli.run()

@ssbarnea
Copy link
Member

ssbarnea commented Oct 7, 2022

@stefan-as Most reasons are historical and I wanted to switch to do the same as you. Officially using python is not endorsed, but we already did private imports from Ansible, so that would be the worst part.

Still, I am confident that using python could introduce a huge speed boosts. Are you willing to try a PR that adds this? I am sure you will make many happy.

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

3 participants