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

Unnecessary PATH injection causes a warning #4212

Closed
janmondry opened this issue Jun 6, 2024 · 1 comment
Closed

Unnecessary PATH injection causes a warning #4212

janmondry opened this issue Jun 6, 2024 · 1 comment
Labels

Comments

@janmondry
Copy link

Summary

There's an issue that causes printing an unnecessary warning and unnecessary injection of a certain path to PATH environmental variable.

https://github.com/ansible/ansible-lint/blob/main/src/ansiblelint/__main__.py#L464
if (parent / "ansible").exists() and str(parent) not in paths

Personally I encountered a case when:

  • a path in PATH ends with a trailing slash (which is correct) (eg. /app/bin/), but
  • ansible-lint looked for a string without the trailing slash, as returned by str(parent) (eg. /app/bin),
  • which resulted in adding the unnecessary path to PATH and printing a warning (example PATH could contain something like /app/bin/:/app/bin)

Comparing Path objects instead of strings would solve the problem.

For reference - I created a PR (but couldn't get the checks to work): #4210

Issue Type
  • Bug Report
OS / ENVIRONMENT

not relevant

STEPS TO REPRODUCE

Prerequisite: have ansible installed in /app/bin/ansible and ansible-lint in /app/bin/ansible-lint

Desired Behavior
> PATH=/app/bin/ ansible-lint
[...]  # no warning
> PATH=/app/bin ansible-lint
[...]  # no warning
Actual Behavior
> PATH=/app/bin/ ansible-lint
WARNING: PATH altered to include /app/bin :: This is usually a sign of broken local setup, which can cause unexpected behaviors.
[...]
> PATH=/app/bin ansible-lint
[...]  # no warning
@janmondry janmondry added bug new Triage required labels Jun 6, 2024
@ssbarnea ssbarnea removed the new Triage required label Jun 19, 2024
@ssbarnea
Copy link
Member

Sorry but nobody does append a slash in PATH elements, we will be closing this as an wontfix because it looks like a user configuration issues.

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

No branches or pull requests

2 participants