Skip to content

python-exec triggers a warning when starting ansible-lint #12

Open

Description

@pva

Whenever I run ansible-lint on Gentoo system, I get a warning:

WARNING: PATH altered to include /usr/lib/python-exec/python3.10 :: This is usually a sign of broken local setup, which can cause unexpected behaviors.

This is because ansible-lint adds a binary path into system $PATH and the path binary has (/usr/lib/python-exec/python3.10/) is not in system PATH:
https://github.com/ansible/ansible-lint/blob/main/src/ansiblelint/__main__.py#L468

I think python-exec should add a binary path to PATH. Something like this (before exec()) fixed issue for me:

os.environ["PATH"] += os.pathsep + os.path.join('/usr/lib/python-exec', EPYTHON)

Activity

  1. mgorny commented on Sep 17, 2024

    @mgorny
    Member

    I'm not convinced this is generally a good idea, and it is definitely a change in behavior.

    Currently, if direct executable doesn't support preferred impl, other programs will still run through python-exec and run with preferred impl. With this change, the non-preferred impl will be forced for everything.

  2. pva commented on Sep 17, 2024

    @pva
    Author

    I'm not convinced as well. It's possible to patch ansible-lint but I failed to think of a good way to detect that program was running with the help of python-exec.

  3. eli-schwartz commented on Sep 18, 2024

    @eli-schwartz

    It has never been entirely clear to me why python-exec supports its own use as a shebang to smartly detect the preferred EPYTHON but then uses that facility to execute a launcher script which reads and exec()'s the real script in combination with argv mangling.

    One possible solution to this reported case would be to stop doing that, and simply inject itself into the existing script's shebang directly in /usr/bin. What would be the downside of such an approach? (I assume that this must have been considered at some point and rejected, but I haven't seen any documentation on why.)

  4. mgorny commented on Sep 18, 2024

    @mgorny
    Member

    Please ask in plain English.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions