Skip to content

Default rcfile locations are scanned even when --rcfile option is specified #7169

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

Closed
daisuke834 opened this issue Jul 12, 2022 · 1 comment · Fixed by #7423
Closed

Default rcfile locations are scanned even when --rcfile option is specified #7169

daisuke834 opened this issue Jul 12, 2022 · 1 comment · Fixed by #7423
Assignees
Labels
Bug 🪲 Configuration Related to configuration Needs PR This issue is accepted, sufficiently specified and now needs an implementation Regression
Milestone

Comments

@daisuke834
Copy link

Bug description

With the latest version 2.14.4, pylint scans the default rcfile locations even when --rcfile option with valid rcfile path is specified. It is problematic because it caused a permission error when an user doesn't have an access permissions to the pre-determined default path of default rcfile files.

Configuration

No response

Command used

$ pylint --rcfile /config/pyproject.toml

Pylint output

Traceback (most recent call last):
  File "/home/myhome/.pyenv/versions/3.10.5/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/__init__.py", line 22, in run_pylint
    from pylint.lint import Run as PylintRun
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/lint/__init__.py", line 19, in <module>
    from pylint.config.exceptions import ArgumentPreprocessingError
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/config/__init__.py", line 27, in <module>
    from pylint.config.environment_variable import PYLINTRC
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/config/environment_variable.py", line 11, in <module>
    PYLINTRC = find_pylintrc()
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/config/find_default_config_files.py", line 94, in find_pylintrc
    for config_file in find_default_config_files():
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/config/find_default_config_files.py", line 76, in find_default_config_files
    if home_rc.is_file():
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/pathlib.py", line 1322, in is_file
    return S_ISREG(self.stat().st_mode)
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/pathlib.py", line 1097, in stat
    return self._accessor.stat(self, follow_symlinks=follow_symlinks)
PermissionError: [Errno 13] Permission denied: '/home/myhome/.config/pylintrc'

Expected behavior

With the prior version at least 2.13.5, the problem didn't happen. 2.13.5 don't seem to scan default rcfile locations when --rcfile option with valid rcfile path is specified. Similar to 2.13.5, I think the latest version 2.14.4 and later version are also expected to skip scanning the default paths when --rcfile option with valid path is specified.

Pylint version

Used 2.14.4.

`$ pylint --version` didn't work because of the issue.

$ pylint --version
Traceback (most recent call last):
  File "/home/myhome/.pyenv/versions/3.10.5/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/__init__.py", line 22, in run_pylint
    from pylint.lint import Run as PylintRun
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/lint/__init__.py", line 19, in <module>
    from pylint.config.exceptions import ArgumentPreprocessingError
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/config/__init__.py", line 27, in <module>
    from pylint.config.environment_variable import PYLINTRC
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/config/environment_variable.py", line 11, in <module>
    PYLINTRC = find_pylintrc()
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/config/find_default_config_files.py", line 94, in find_pylintrc
    for config_file in find_default_config_files():
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/config/find_default_config_files.py", line 76, in find_default_config_files
    if home_rc.is_file():
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/pathlib.py", line 1322, in is_file
    return S_ISREG(self.stat().st_mode)
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/pathlib.py", line 1097, in stat
    return self._accessor.stat(self, follow_symlinks=follow_symlinks)
PermissionError: [Errno 13] Permission denied: '/home/myhome/.config/pylintrc'

OS / Environment

Ubuntu focal by using the docker image via FROM ubuntu:focal-20220531

Additional dependencies

No response

@daisuke834 daisuke834 added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jul 12, 2022
@daisuke834
Copy link
Author

Tested at each version

  • v2.13.6: OK
  • v2.13.9: OK
  • v2.14.0: NG (default rc files were scanned and caused the permission error)
  • v2.14.2: NG (default rc files were scanned and caused the permission error)
  • v2.14.4: NG (default rc files were scanned and caused the permission error)

@DanielNoord DanielNoord added Bug 🪲 Configuration Related to configuration Regression Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Jul 12, 2022
@DanielNoord DanielNoord added this to the 2.15.1 milestone Sep 6, 2022
@DanielNoord DanielNoord self-assigned this Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Configuration Related to configuration Needs PR This issue is accepted, sufficiently specified and now needs an implementation Regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants